mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Align flutter pub get/upgrade/add/remove/downgrade
(#117896)
* Align `flutter pub get/upgrade/add/remove/downgrade` * Add final . to command description * Remove trailing whitespace * Don't print message that command is being run * Update expectations * Use relative path * Remove duplicated line * Improve function dartdoc
This commit is contained in:
parent
cf529ec57e
commit
b7881e5b64
@ -20,10 +20,10 @@ import '../runner/flutter_command.dart';
|
|||||||
|
|
||||||
class PackagesCommand extends FlutterCommand {
|
class PackagesCommand extends FlutterCommand {
|
||||||
PackagesCommand() {
|
PackagesCommand() {
|
||||||
addSubcommand(PackagesGetCommand('get', false));
|
addSubcommand(PackagesGetCommand('get', "Get the current package's dependencies.", PubContext.pubGet));
|
||||||
addSubcommand(PackagesInteractiveGetCommand('upgrade', "Upgrade the current package's dependencies to latest versions."));
|
addSubcommand(PackagesGetCommand('upgrade', "Upgrade the current package's dependencies to latest versions.", PubContext.pubUpgrade));
|
||||||
addSubcommand(PackagesInteractiveGetCommand('add', 'Add a dependency to pubspec.yaml.'));
|
addSubcommand(PackagesGetCommand('add', 'Add a dependency to pubspec.yaml.', PubContext.pubAdd));
|
||||||
addSubcommand(PackagesInteractiveGetCommand('remove', 'Removes a dependency from the current package.'));
|
addSubcommand(PackagesGetCommand('remove', 'Removes a dependency from the current package.', PubContext.pubRemove));
|
||||||
addSubcommand(PackagesTestCommand());
|
addSubcommand(PackagesTestCommand());
|
||||||
addSubcommand(PackagesForwardCommand('publish', 'Publish the current package to pub.dartlang.org.', requiresPubspec: true));
|
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('downgrade', 'Downgrade packages in a Flutter project.', requiresPubspec: true));
|
||||||
@ -56,136 +56,6 @@ class PackagesCommand extends FlutterCommand {
|
|||||||
Future<FlutterCommandResult> runCommand() async => FlutterCommandResult.fail();
|
Future<FlutterCommandResult> runCommand() async => FlutterCommandResult.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
class PackagesGetCommand extends FlutterCommand {
|
|
||||||
PackagesGetCommand(this.name, this.upgrade) {
|
|
||||||
argParser.addFlag('offline',
|
|
||||||
negatable: false,
|
|
||||||
help: 'Use cached packages instead of accessing the network.',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
final String name;
|
|
||||||
|
|
||||||
final bool upgrade;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get description {
|
|
||||||
return '${ upgrade ? "Upgrade" : "Get" } packages in a Flutter project.';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get invocation {
|
|
||||||
return '${runner!.executableName} pub $name [<target directory>]';
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The pub packages usage values are incorrect since these are calculated/sent
|
|
||||||
/// before pub get completes. This needs to be performed after dependency resolution.
|
|
||||||
@override
|
|
||||||
Future<CustomDimensions> get usageValues async {
|
|
||||||
final ArgResults argumentResults = argResults!;
|
|
||||||
final String? workingDirectory = argumentResults.rest.length == 1 ? argumentResults.rest[0] : null;
|
|
||||||
final String? target = findProjectRoot(globals.fs, workingDirectory);
|
|
||||||
if (target == null) {
|
|
||||||
return const CustomDimensions();
|
|
||||||
}
|
|
||||||
|
|
||||||
int numberPlugins;
|
|
||||||
|
|
||||||
final FlutterProject rootProject = FlutterProject.fromDirectory(globals.fs.directory(target));
|
|
||||||
// Do not send plugin analytics if pub has not run before.
|
|
||||||
final bool hasPlugins = rootProject.flutterPluginsDependenciesFile.existsSync()
|
|
||||||
&& rootProject.packageConfigFile.existsSync();
|
|
||||||
if (hasPlugins) {
|
|
||||||
// Do not fail pub get if package config files are invalid before pub has
|
|
||||||
// had a chance to run.
|
|
||||||
final List<Plugin> plugins = await findPlugins(rootProject, throwOnError: false);
|
|
||||||
numberPlugins = plugins.length;
|
|
||||||
} else {
|
|
||||||
numberPlugins = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CustomDimensions(
|
|
||||||
commandPackagesNumberPlugins: numberPlugins,
|
|
||||||
commandPackagesProjectModule: rootProject.isModule,
|
|
||||||
commandPackagesAndroidEmbeddingVersion: rootProject.android.getEmbeddingVersion().toString().split('.').last,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _runPubGet(String directory, FlutterProject flutterProject) async {
|
|
||||||
if (flutterProject.manifest.generateSyntheticPackage) {
|
|
||||||
final Environment environment = Environment(
|
|
||||||
artifacts: globals.artifacts!,
|
|
||||||
logger: globals.logger,
|
|
||||||
cacheDir: globals.cache.getRoot(),
|
|
||||||
engineVersion: globals.flutterVersion.engineRevision,
|
|
||||||
fileSystem: globals.fs,
|
|
||||||
flutterRootDir: globals.fs.directory(Cache.flutterRoot),
|
|
||||||
outputDir: globals.fs.directory(getBuildDirectory()),
|
|
||||||
processManager: globals.processManager,
|
|
||||||
platform: globals.platform,
|
|
||||||
usage: globals.flutterUsage,
|
|
||||||
projectDir: flutterProject.directory,
|
|
||||||
generateDartPluginRegistry: true,
|
|
||||||
);
|
|
||||||
|
|
||||||
await generateLocalizationsSyntheticPackage(
|
|
||||||
environment: environment,
|
|
||||||
buildSystem: globals.buildSystem,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final Stopwatch pubGetTimer = Stopwatch()..start();
|
|
||||||
try {
|
|
||||||
await pub.get(
|
|
||||||
context: PubContext.pubGet,
|
|
||||||
project: flutterProject,
|
|
||||||
upgrade: upgrade,
|
|
||||||
shouldSkipThirdPartyGenerator: false,
|
|
||||||
offline: boolArgDeprecated('offline'),
|
|
||||||
);
|
|
||||||
pubGetTimer.stop();
|
|
||||||
globals.flutterUsage.sendTiming('pub', 'get', pubGetTimer.elapsed, label: 'success');
|
|
||||||
// Not limiting to catching Exception because the exception is rethrown.
|
|
||||||
} catch (_) { // ignore: avoid_catches_without_on_clauses
|
|
||||||
pubGetTimer.stop();
|
|
||||||
globals.flutterUsage.sendTiming('pub', 'get', pubGetTimer.elapsed, label: 'failure');
|
|
||||||
rethrow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<FlutterCommandResult> runCommand() async {
|
|
||||||
final ArgResults argumentResults = argResults!;
|
|
||||||
if (argumentResults.rest.length > 1) {
|
|
||||||
throwToolExit('Too many arguments.\n$usage');
|
|
||||||
}
|
|
||||||
|
|
||||||
final String? workingDirectory = argumentResults.rest.length == 1 ? argumentResults.rest[0] : null;
|
|
||||||
final String? target = findProjectRoot(globals.fs, workingDirectory);
|
|
||||||
if (target == null) {
|
|
||||||
throwToolExit(
|
|
||||||
'Expected to find project root in '
|
|
||||||
'${ workingDirectory ?? "current working directory" }.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final FlutterProject rootProject = FlutterProject.fromDirectory(globals.fs.directory(target));
|
|
||||||
|
|
||||||
// This will also resolve dependencies for the example folder,
|
|
||||||
await _runPubGet(target, rootProject);
|
|
||||||
|
|
||||||
// We need to regenerate the platform specific tooling for both the project
|
|
||||||
// itself and example (if present).
|
|
||||||
await rootProject.regeneratePlatformSpecificTooling();
|
|
||||||
if (rootProject.hasExampleApp && rootProject.example.pubspecFile.existsSync()) {
|
|
||||||
final FlutterProject exampleProject = rootProject.example;
|
|
||||||
await exampleProject.regeneratePlatformSpecificTooling();
|
|
||||||
}
|
|
||||||
|
|
||||||
return FlutterCommandResult.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class PackagesTestCommand extends FlutterCommand {
|
class PackagesTestCommand extends FlutterCommand {
|
||||||
PackagesTestCommand() {
|
PackagesTestCommand() {
|
||||||
requiresPubspecYaml();
|
requiresPubspecYaml();
|
||||||
@ -223,6 +93,8 @@ class PackagesForwardCommand extends FlutterCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PubContext context = PubContext.pubForward;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ArgParser argParser = ArgParser.allowAnything();
|
ArgParser argParser = ArgParser.allowAnything();
|
||||||
|
|
||||||
@ -247,7 +119,11 @@ class PackagesForwardCommand extends FlutterCommand {
|
|||||||
Future<FlutterCommandResult> runCommand() async {
|
Future<FlutterCommandResult> runCommand() async {
|
||||||
final List<String> subArgs = argResults!.rest.toList()
|
final List<String> subArgs = argResults!.rest.toList()
|
||||||
..removeWhere((String arg) => arg == '--');
|
..removeWhere((String arg) => arg == '--');
|
||||||
await pub.interactively(<String>[_commandName, ...subArgs], stdio: globals.stdio);
|
await pub.interactively(
|
||||||
|
<String>[ _commandName, ...subArgs],
|
||||||
|
context: context,
|
||||||
|
command: _commandName,
|
||||||
|
);
|
||||||
return FlutterCommandResult.success();
|
return FlutterCommandResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,21 +146,31 @@ class PackagesPassthroughCommand extends FlutterCommand {
|
|||||||
return '${runner!.executableName} packages pub [<arguments...>]';
|
return '${runner!.executableName} packages pub [<arguments...>]';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final PubContext _context = PubContext.pubPassThrough;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<FlutterCommandResult> runCommand() async {
|
Future<FlutterCommandResult> runCommand() async {
|
||||||
await pub.interactively(argResults!.rest, stdio: globals.stdio);
|
await pub.interactively(
|
||||||
|
command: 'pub',
|
||||||
|
argResults!.rest,
|
||||||
|
context: _context,
|
||||||
|
);
|
||||||
return FlutterCommandResult.success();
|
return FlutterCommandResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PackagesInteractiveGetCommand extends FlutterCommand {
|
/// Represents the pub sub-commands that makes package-resolutions.
|
||||||
PackagesInteractiveGetCommand(this._commandName, this._description);
|
class PackagesGetCommand extends FlutterCommand {
|
||||||
|
PackagesGetCommand(this._commandName, this._description, this._context);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ArgParser argParser = ArgParser.allowAnything();
|
ArgParser argParser = ArgParser.allowAnything();
|
||||||
|
|
||||||
final String _commandName;
|
final String _commandName;
|
||||||
final String _description;
|
final String _description;
|
||||||
|
final PubContext _context;
|
||||||
|
|
||||||
|
FlutterProject? _rootProject;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get name => _commandName;
|
String get name => _commandName;
|
||||||
@ -300,29 +186,89 @@ class PackagesInteractiveGetCommand extends FlutterCommand {
|
|||||||
return '${runner!.executableName} pub $_commandName [<arguments...>]';
|
return '${runner!.executableName} pub $_commandName [<arguments...>]';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An [ArgParser] that accepts all options and flags that the
|
||||||
|
///
|
||||||
|
/// `pub get`
|
||||||
|
/// `pub upgrade`
|
||||||
|
/// `pub downgrade`
|
||||||
|
/// `pub add`
|
||||||
|
/// `pub remove`
|
||||||
|
///
|
||||||
|
/// commands accept.
|
||||||
|
ArgParser get _permissiveArgParser {
|
||||||
|
final ArgParser argParser = ArgParser();
|
||||||
|
argParser.addOption('directory', abbr: 'C');
|
||||||
|
argParser.addFlag('offline');
|
||||||
|
argParser.addFlag('dry-run', abbr: 'n');
|
||||||
|
argParser.addFlag('help', abbr: 'h');
|
||||||
|
argParser.addFlag('enforce-lockfile');
|
||||||
|
argParser.addFlag('precompile');
|
||||||
|
argParser.addFlag('major-versions');
|
||||||
|
argParser.addFlag('null-safety');
|
||||||
|
argParser.addFlag('example', defaultsTo: true);
|
||||||
|
argParser.addOption('sdk');
|
||||||
|
argParser.addOption('path');
|
||||||
|
argParser.addOption('hosted-url');
|
||||||
|
argParser.addOption('git-url');
|
||||||
|
argParser.addOption('git-ref');
|
||||||
|
argParser.addOption('git-path');
|
||||||
|
argParser.addFlag('dev');
|
||||||
|
return argParser;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<FlutterCommandResult> runCommand() async {
|
Future<FlutterCommandResult> runCommand() async {
|
||||||
List<String> rest = argResults!.rest;
|
List<String> rest = argResults!.rest;
|
||||||
final bool isHelp = rest.contains('-h') || rest.contains('--help');
|
bool isHelp = false;
|
||||||
|
bool example = true;
|
||||||
|
bool exampleWasParsed = false;
|
||||||
|
String? directoryOption;
|
||||||
|
bool dryRun = false;
|
||||||
|
try {
|
||||||
|
final ArgResults results = _permissiveArgParser.parse(rest);
|
||||||
|
isHelp = results['help'] as bool;
|
||||||
|
directoryOption = results['directory'] as String?;
|
||||||
|
example = results['example'] as bool;
|
||||||
|
exampleWasParsed = results.wasParsed('example');
|
||||||
|
dryRun = results['dry-run'] as bool;
|
||||||
|
} on ArgParserException {
|
||||||
|
// Let pub give the error message.
|
||||||
|
}
|
||||||
String? target;
|
String? target;
|
||||||
if (rest.length == 1 && (rest.single.contains('/') || rest.single.contains(r'\'))) {
|
FlutterProject? rootProject;
|
||||||
|
|
||||||
|
if (!isHelp) {
|
||||||
|
if (directoryOption == null && rest.length == 1 &&
|
||||||
|
((rest.single.contains('/') || rest.single.contains(r'\')) ||
|
||||||
|
name == 'get')) {
|
||||||
// For historical reasons, if there is one argument to the command and it contains
|
// For historical reasons, if there is one argument to the command and it contains
|
||||||
// a multiple-component path (i.e. contains a slash) then we use that to determine
|
// a multiple-component path (i.e. contains a slash) then we use that to determine
|
||||||
// to which project we're applying the command.
|
// to which project we're applying the command.
|
||||||
target = findProjectRoot(globals.fs, rest.single);
|
target = findProjectRoot(globals.fs, rest.single);
|
||||||
|
|
||||||
|
globals.printWarning('''
|
||||||
|
Using a naked argument for directory is deprecated and will stop working in a future Flutter release.
|
||||||
|
|
||||||
|
Use --directory instead.''');
|
||||||
|
if (target == null) {
|
||||||
|
throwToolExit('Expected to find project root in ${rest.single}.');
|
||||||
|
}
|
||||||
rest = <String>[];
|
rest = <String>[];
|
||||||
} else {
|
} else {
|
||||||
target = findProjectRoot(globals.fs);
|
target = findProjectRoot(globals.fs, directoryOption);
|
||||||
}
|
|
||||||
|
|
||||||
FlutterProject? flutterProject;
|
|
||||||
if (!isHelp) {
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
|
if (directoryOption == null) {
|
||||||
throwToolExit('Expected to find project root in current working directory.');
|
throwToolExit('Expected to find project root in current working directory.');
|
||||||
|
} else {
|
||||||
|
throwToolExit('Expected to find project root in $directoryOption.');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
flutterProject = FlutterProject.fromDirectory(globals.fs.directory(target));
|
|
||||||
|
|
||||||
if (flutterProject.manifest.generateSyntheticPackage) {
|
rootProject = FlutterProject.fromDirectory(globals.fs.directory(target));
|
||||||
|
_rootProject = rootProject;
|
||||||
|
|
||||||
|
if (rootProject.manifest.generateSyntheticPackage) {
|
||||||
final Environment environment = Environment(
|
final Environment environment = Environment(
|
||||||
artifacts: globals.artifacts!,
|
artifacts: globals.artifacts!,
|
||||||
logger: globals.logger,
|
logger: globals.logger,
|
||||||
@ -334,7 +280,7 @@ class PackagesInteractiveGetCommand extends FlutterCommand {
|
|||||||
processManager: globals.processManager,
|
processManager: globals.processManager,
|
||||||
platform: globals.platform,
|
platform: globals.platform,
|
||||||
usage: globals.flutterUsage,
|
usage: globals.flutterUsage,
|
||||||
projectDir: flutterProject.directory,
|
projectDir: rootProject.directory,
|
||||||
generateDartPluginRegistry: true,
|
generateDartPluginRegistry: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -344,17 +290,70 @@ class PackagesInteractiveGetCommand extends FlutterCommand {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
final String? relativeTarget = target == null ? null : globals.fs.path.relative(target);
|
||||||
|
|
||||||
final List<String> subArgs = rest.toList()..removeWhere((String arg) => arg == '--');
|
final List<String> subArgs = rest.toList()..removeWhere((String arg) => arg == '--');
|
||||||
|
final Stopwatch timer = Stopwatch()..start();
|
||||||
|
try {
|
||||||
await pub.interactively(
|
await pub.interactively(
|
||||||
<String>[name, ...subArgs],
|
<String>[
|
||||||
directory: target,
|
name,
|
||||||
stdio: globals.stdio,
|
...subArgs,
|
||||||
touchesPackageConfig: !isHelp,
|
// `dart pub get` and friends defaults to `--no-example`.
|
||||||
generateSyntheticPackage: flutterProject?.manifest.generateSyntheticPackage ?? false,
|
if(!exampleWasParsed && target != null) '--example',
|
||||||
|
if(directoryOption == null && relativeTarget != null) ...<String>['--directory', relativeTarget],
|
||||||
|
],
|
||||||
|
project: rootProject,
|
||||||
|
context: _context,
|
||||||
|
command: name,
|
||||||
|
touchesPackageConfig: !(isHelp || dryRun),
|
||||||
);
|
);
|
||||||
|
globals.flutterUsage.sendTiming('pub', 'get', timer.elapsed, label: 'success');
|
||||||
|
// Not limiting to catching Exception because the exception is rethrown.
|
||||||
|
} catch (_) { // ignore: avoid_catches_without_on_clauses
|
||||||
|
globals.flutterUsage.sendTiming('pub', 'get', timer.elapsed, label: 'failure');
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rootProject != null) {
|
||||||
|
// We need to regenerate the platform specific tooling for both the project
|
||||||
|
// itself and example(if present).
|
||||||
|
await rootProject.regeneratePlatformSpecificTooling();
|
||||||
|
if (example && rootProject.hasExampleApp && rootProject.example.pubspecFile.existsSync()) {
|
||||||
|
final FlutterProject exampleProject = rootProject.example;
|
||||||
|
await exampleProject.regeneratePlatformSpecificTooling();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await flutterProject?.regeneratePlatformSpecificTooling();
|
|
||||||
return FlutterCommandResult.success();
|
return FlutterCommandResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The pub packages usage values are incorrect since these are calculated/sent
|
||||||
|
/// before pub get completes. This needs to be performed after dependency resolution.
|
||||||
|
@override
|
||||||
|
Future<CustomDimensions> get usageValues async {
|
||||||
|
final FlutterProject? rootProject = _rootProject;
|
||||||
|
if (rootProject == null) {
|
||||||
|
return const CustomDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
|
int numberPlugins;
|
||||||
|
// Do not send plugin analytics if pub has not run before.
|
||||||
|
final bool hasPlugins = rootProject.flutterPluginsDependenciesFile.existsSync()
|
||||||
|
&& rootProject.packageConfigFile.existsSync();
|
||||||
|
if (hasPlugins) {
|
||||||
|
// Do not fail pub get if package config files are invalid before pub has
|
||||||
|
// had a chance to run.
|
||||||
|
final List<Plugin> plugins = await findPlugins(rootProject, throwOnError: false);
|
||||||
|
numberPlugins = plugins.length;
|
||||||
|
} else {
|
||||||
|
numberPlugins = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CustomDimensions(
|
||||||
|
commandPackagesNumberPlugins: numberPlugins,
|
||||||
|
commandPackagesProjectModule: rootProject.isModule,
|
||||||
|
commandPackagesAndroidEmbeddingVersion: rootProject.android.getEmbeddingVersion().toString().split('.').last,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,10 @@ class PubContext {
|
|||||||
static final PubContext interactive = PubContext._(<String>['interactive']);
|
static final PubContext interactive = PubContext._(<String>['interactive']);
|
||||||
static final PubContext pubGet = PubContext._(<String>['get']);
|
static final PubContext pubGet = PubContext._(<String>['get']);
|
||||||
static final PubContext pubUpgrade = PubContext._(<String>['upgrade']);
|
static final PubContext pubUpgrade = PubContext._(<String>['upgrade']);
|
||||||
|
static final PubContext pubAdd = PubContext._(<String>['add']);
|
||||||
|
static final PubContext pubRemove = PubContext._(<String>['remove']);
|
||||||
static final PubContext pubForward = PubContext._(<String>['forward']);
|
static final PubContext pubForward = PubContext._(<String>['forward']);
|
||||||
|
static final PubContext pubPassThrough = PubContext._(<String>['passthrough']);
|
||||||
static final PubContext runTest = PubContext._(<String>['run_test']);
|
static final PubContext runTest = PubContext._(<String>['run_test']);
|
||||||
static final PubContext flutterTests = PubContext._(<String>['flutter_tests']);
|
static final PubContext flutterTests = PubContext._(<String>['flutter_tests']);
|
||||||
static final PubContext updatePackages = PubContext._(<String>['update_packages']);
|
static final PubContext updatePackages = PubContext._(<String>['update_packages']);
|
||||||
@ -161,7 +164,7 @@ abstract class Pub {
|
|||||||
required Stdio stdio,
|
required Stdio stdio,
|
||||||
}) = _DefaultPub.test;
|
}) = _DefaultPub.test;
|
||||||
|
|
||||||
/// Runs `pub get` or `pub upgrade` for [project].
|
/// Runs `pub get` for [project].
|
||||||
///
|
///
|
||||||
/// [context] provides extra information to package server requests to
|
/// [context] provides extra information to package server requests to
|
||||||
/// understand usage.
|
/// understand usage.
|
||||||
@ -173,7 +176,6 @@ abstract class Pub {
|
|||||||
Future<void> get({
|
Future<void> get({
|
||||||
required PubContext context,
|
required PubContext context,
|
||||||
required FlutterProject project,
|
required FlutterProject project,
|
||||||
bool skipIfAbsent = false,
|
|
||||||
bool upgrade = false,
|
bool upgrade = false,
|
||||||
bool offline = false,
|
bool offline = false,
|
||||||
String? flutterRootOverride,
|
String? flutterRootOverride,
|
||||||
@ -203,14 +205,23 @@ abstract class Pub {
|
|||||||
|
|
||||||
/// Runs pub in 'interactive' mode.
|
/// Runs pub in 'interactive' mode.
|
||||||
///
|
///
|
||||||
/// directly piping the stdin stream of this process to that of pub, and the
|
/// This will run the pub process with StdioInherited (unless [_stdio] is set
|
||||||
/// stdout/stderr stream of pub to the corresponding streams of this process.
|
/// for testing).
|
||||||
|
///
|
||||||
|
/// The pub process will be run in current working directory, so `--directory`
|
||||||
|
/// should be passed appropriately in [arguments]. This ensures output from
|
||||||
|
/// pub will refer to relative paths correctly.
|
||||||
|
///
|
||||||
|
/// [touchesPackageConfig] should be true if this is a command expexted to
|
||||||
|
/// create a new `.dart_tool/package_config.json` file.
|
||||||
Future<void> interactively(
|
Future<void> interactively(
|
||||||
List<String> arguments, {
|
List<String> arguments, {
|
||||||
String? directory,
|
FlutterProject? project,
|
||||||
required io.Stdio stdio,
|
required PubContext context,
|
||||||
|
required String command,
|
||||||
bool touchesPackageConfig = false,
|
bool touchesPackageConfig = false,
|
||||||
bool generateSyntheticPackage = false,
|
bool generateSyntheticPackage = false,
|
||||||
|
bool printProgress = true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +279,6 @@ class _DefaultPub implements Pub {
|
|||||||
Future<void> get({
|
Future<void> get({
|
||||||
required PubContext context,
|
required PubContext context,
|
||||||
required FlutterProject project,
|
required FlutterProject project,
|
||||||
bool skipIfAbsent = false,
|
|
||||||
bool upgrade = false,
|
bool upgrade = false,
|
||||||
bool offline = false,
|
bool offline = false,
|
||||||
bool generateSyntheticPackage = false,
|
bool generateSyntheticPackage = false,
|
||||||
@ -280,8 +290,6 @@ class _DefaultPub implements Pub {
|
|||||||
}) async {
|
}) async {
|
||||||
final String directory = project.directory.path;
|
final String directory = project.directory.path;
|
||||||
final File packageConfigFile = project.packageConfigFile;
|
final File packageConfigFile = project.packageConfigFile;
|
||||||
final Directory generatedDirectory = _fileSystem.directory(
|
|
||||||
_fileSystem.path.join(directory, '.dart_tool', 'flutter_gen'));
|
|
||||||
final File lastVersion = _fileSystem.file(
|
final File lastVersion = _fileSystem.file(
|
||||||
_fileSystem.path.join(directory, '.dart_tool', 'version'));
|
_fileSystem.path.join(directory, '.dart_tool', 'version'));
|
||||||
final File currentVersion = _fileSystem.file(
|
final File currentVersion = _fileSystem.file(
|
||||||
@ -352,25 +360,7 @@ class _DefaultPub implements Pub {
|
|||||||
flutterRootOverride: flutterRootOverride,
|
flutterRootOverride: flutterRootOverride,
|
||||||
printProgress: printProgress
|
printProgress: printProgress
|
||||||
);
|
);
|
||||||
|
await _updateVersionAndPackageConfig(project);
|
||||||
if (!packageConfigFile.existsSync()) {
|
|
||||||
throwToolExit('$directory: pub did not create .dart_tools/package_config.json file.');
|
|
||||||
}
|
|
||||||
lastVersion.writeAsStringSync(currentVersion.readAsStringSync());
|
|
||||||
await _updatePackageConfig(
|
|
||||||
packageConfigFile,
|
|
||||||
generatedDirectory,
|
|
||||||
project.manifest.generateSyntheticPackage,
|
|
||||||
);
|
|
||||||
if (project.hasExampleApp && project.example.pubspecFile.existsSync()) {
|
|
||||||
final Directory exampleGeneratedDirectory = _fileSystem.directory(
|
|
||||||
_fileSystem.path.join(project.example.directory.path, '.dart_tool', 'flutter_gen'));
|
|
||||||
await _updatePackageConfig(
|
|
||||||
project.example.packageConfigFile,
|
|
||||||
exampleGeneratedDirectory,
|
|
||||||
project.example.manifest.generateSyntheticPackage,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs pub with [arguments] and [ProcessStartMode.inheritStdio] mode.
|
/// Runs pub with [arguments] and [ProcessStartMode.inheritStdio] mode.
|
||||||
@ -392,9 +382,6 @@ class _DefaultPub implements Pub {
|
|||||||
String? flutterRootOverride,
|
String? flutterRootOverride,
|
||||||
}) async {
|
}) async {
|
||||||
int exitCode;
|
int exitCode;
|
||||||
if (printProgress) {
|
|
||||||
_logger.printStatus('Running "flutter pub $command" in ${_fileSystem.path.basename(directory)}...');
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<String> pubCommand = _pubCommand(arguments);
|
final List<String> pubCommand = _pubCommand(arguments);
|
||||||
final Map<String, String> pubEnvironment = await _createPubEnvironment(context, flutterRootOverride);
|
final Map<String, String> pubEnvironment = await _createPubEnvironment(context, flutterRootOverride);
|
||||||
@ -567,64 +554,22 @@ class _DefaultPub implements Pub {
|
|||||||
@override
|
@override
|
||||||
Future<void> interactively(
|
Future<void> interactively(
|
||||||
List<String> arguments, {
|
List<String> arguments, {
|
||||||
String? directory,
|
FlutterProject? project,
|
||||||
required io.Stdio stdio,
|
required PubContext context,
|
||||||
|
required String command,
|
||||||
bool touchesPackageConfig = false,
|
bool touchesPackageConfig = false,
|
||||||
bool generateSyntheticPackage = false,
|
bool generateSyntheticPackage = false,
|
||||||
|
bool printProgress = true,
|
||||||
}) async {
|
}) async {
|
||||||
// Fully resolved pub or pub.bat is calculated based on current platform.
|
await _runWithStdioInherited(
|
||||||
final io.Process process = await _processUtils.start(
|
arguments,
|
||||||
_pubCommand(<String>[
|
command: command,
|
||||||
if (_logger.supportsColor) '--color',
|
directory: _fileSystem.currentDirectory.path,
|
||||||
...arguments,
|
context: context,
|
||||||
]),
|
printProgress: printProgress,
|
||||||
workingDirectory: directory,
|
|
||||||
environment: await _createPubEnvironment(PubContext.interactive),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Pipe the Flutter tool stdin to the pub stdin.
|
|
||||||
unawaited(process.stdin.addStream(stdio.stdin)
|
|
||||||
// If pub exits unexpectedly with an error, that will be reported below
|
|
||||||
// by the tool exit after the exit code check.
|
|
||||||
.catchError((dynamic err, StackTrace stack) {
|
|
||||||
_logger.printTrace('Echoing stdin to the pub subprocess failed:');
|
|
||||||
_logger.printTrace('$err\n$stack');
|
|
||||||
}
|
|
||||||
));
|
|
||||||
|
|
||||||
// Pipe the pub stdout and stderr to the tool stdout and stderr.
|
|
||||||
try {
|
|
||||||
await Future.wait<dynamic>(<Future<dynamic>>[
|
|
||||||
stdio.addStdoutStream(process.stdout),
|
|
||||||
stdio.addStderrStream(process.stderr),
|
|
||||||
]);
|
|
||||||
} on Exception catch (err, stack) {
|
|
||||||
_logger.printTrace('Echoing stdout or stderr from the pub subprocess failed:');
|
|
||||||
_logger.printTrace('$err\n$stack');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for pub to exit.
|
|
||||||
final int code = await process.exitCode;
|
|
||||||
if (code != 0) {
|
|
||||||
throwToolExit('pub finished with exit code $code', exitCode: code);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (touchesPackageConfig) {
|
|
||||||
final String targetDirectory = directory ?? _fileSystem.currentDirectory.path;
|
|
||||||
final File packageConfigFile = _fileSystem.file(
|
|
||||||
_fileSystem.path.join(targetDirectory, '.dart_tool', 'package_config.json'));
|
|
||||||
final Directory generatedDirectory = _fileSystem.directory(
|
|
||||||
_fileSystem.path.join(targetDirectory, '.dart_tool', 'flutter_gen'));
|
|
||||||
final File lastVersion = _fileSystem.file(
|
|
||||||
_fileSystem.path.join(targetDirectory, '.dart_tool', 'version'));
|
|
||||||
final File currentVersion = _fileSystem.file(
|
|
||||||
_fileSystem.path.join(Cache.flutterRoot!, 'version'));
|
|
||||||
lastVersion.writeAsStringSync(currentVersion.readAsStringSync());
|
|
||||||
await _updatePackageConfig(
|
|
||||||
packageConfigFile,
|
|
||||||
generatedDirectory,
|
|
||||||
generateSyntheticPackage,
|
|
||||||
);
|
);
|
||||||
|
if (touchesPackageConfig && project != null) {
|
||||||
|
await _updateVersionAndPackageConfig(project);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -766,23 +711,46 @@ class _DefaultPub implements Pub {
|
|||||||
return environment;
|
return environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update the package configuration file.
|
/// Updates the .dart_tool/version file to be equal to current Flutter
|
||||||
|
/// version.
|
||||||
///
|
///
|
||||||
/// Creates a corresponding `package_config_subset` file that is used by the build
|
/// Calls [_updatePackageConfig] for [project] and [project.example] (if it
|
||||||
/// system to avoid rebuilds caused by an updated pub timestamp.
|
/// exists).
|
||||||
///
|
///
|
||||||
/// if [generateSyntheticPackage] is true then insert flutter_gen synthetic
|
/// This should be called after pub invocations that are expected to update
|
||||||
/// package into the package configuration. This is used by the l10n localization
|
/// the packageConfig.
|
||||||
/// tooling to insert a new reference into the package_config file, allowing the import
|
Future<void> _updateVersionAndPackageConfig(FlutterProject project) async {
|
||||||
/// of a package URI that is not specified in the pubspec.yaml
|
if (!project.packageConfigFile.existsSync()) {
|
||||||
|
throwToolExit('${project.directory}: pub did not create .dart_tools/package_config.json file.');
|
||||||
|
}
|
||||||
|
final File lastVersion = _fileSystem.file(
|
||||||
|
_fileSystem.path.join(project.directory.path, '.dart_tool', 'version'),
|
||||||
|
);
|
||||||
|
final File currentVersion = _fileSystem.file(
|
||||||
|
_fileSystem.path.join(Cache.flutterRoot!, 'version'));
|
||||||
|
lastVersion.writeAsStringSync(currentVersion.readAsStringSync());
|
||||||
|
|
||||||
|
await _updatePackageConfig(project);
|
||||||
|
if (project.hasExampleApp && project.example.pubspecFile.existsSync()) {
|
||||||
|
await _updatePackageConfig(project.example);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Update the package configuration file in [project].
|
||||||
|
///
|
||||||
|
/// Creates a corresponding `package_config_subset` file that is used by the
|
||||||
|
/// build system to avoid rebuilds caused by an updated pub timestamp.
|
||||||
|
///
|
||||||
|
/// if `project.generateSyntheticPackage` is `true` then insert flutter_gen
|
||||||
|
/// synthetic package into the package configuration. This is used by the l10n
|
||||||
|
/// localization tooling to insert a new reference into the package_config
|
||||||
|
/// file, allowing the import of a package URI that is not specified in the
|
||||||
|
/// pubspec.yaml
|
||||||
///
|
///
|
||||||
/// For more information, see:
|
/// For more information, see:
|
||||||
/// * [generateLocalizations], `in lib/src/localizations/gen_l10n.dart`
|
/// * [generateLocalizations], `in lib/src/localizations/gen_l10n.dart`
|
||||||
Future<void> _updatePackageConfig(
|
Future<void> _updatePackageConfig(FlutterProject project) async {
|
||||||
File packageConfigFile,
|
final File packageConfigFile = project.packageConfigFile;
|
||||||
Directory generatedDirectory,
|
|
||||||
bool generateSyntheticPackage,
|
|
||||||
) async {
|
|
||||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(packageConfigFile, logger: _logger);
|
final PackageConfig packageConfig = await loadPackageConfigWithLogging(packageConfigFile, logger: _logger);
|
||||||
|
|
||||||
packageConfigFile.parent
|
packageConfigFile.parent
|
||||||
@ -792,7 +760,7 @@ class _DefaultPub implements Pub {
|
|||||||
_fileSystem,
|
_fileSystem,
|
||||||
));
|
));
|
||||||
|
|
||||||
if (!generateSyntheticPackage) {
|
if (!project.manifest.generateSyntheticPackage) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (packageConfig.packages.any((Package package) => package.name == 'flutter_gen')) {
|
if (packageConfig.packages.any((Package package) => package.name == 'flutter_gen')) {
|
||||||
|
@ -29,7 +29,6 @@ class FakePub extends Fake implements Pub {
|
|||||||
Future<void> get({
|
Future<void> get({
|
||||||
PubContext? context,
|
PubContext? context,
|
||||||
required FlutterProject project,
|
required FlutterProject project,
|
||||||
bool skipIfAbsent = false,
|
|
||||||
bool upgrade = false,
|
bool upgrade = false,
|
||||||
bool offline = false,
|
bool offline = false,
|
||||||
bool generateSyntheticPackage = false,
|
bool generateSyntheticPackage = false,
|
||||||
|
@ -480,7 +480,6 @@ class FakePub extends Fake implements Pub {
|
|||||||
Future<void> get({
|
Future<void> get({
|
||||||
PubContext? context,
|
PubContext? context,
|
||||||
required FlutterProject project,
|
required FlutterProject project,
|
||||||
bool skipIfAbsent = false,
|
|
||||||
bool upgrade = false,
|
bool upgrade = false,
|
||||||
bool offline = false,
|
bool offline = false,
|
||||||
bool generateSyntheticPackage = false,
|
bool generateSyntheticPackage = false,
|
||||||
|
@ -35,7 +35,7 @@ void main() {
|
|||||||
fileSystem.currentDirectory.childFile('.flutter-plugins').createSync();
|
fileSystem.currentDirectory.childFile('.flutter-plugins').createSync();
|
||||||
fileSystem.currentDirectory.childFile('.flutter-plugins-dependencies').createSync();
|
fileSystem.currentDirectory.childFile('.flutter-plugins-dependencies').createSync();
|
||||||
|
|
||||||
final PackagesGetCommand command = PackagesGetCommand('get', false);
|
final PackagesGetCommand command = PackagesGetCommand('get', '', PubContext.pubGet);
|
||||||
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
|
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
|
||||||
|
|
||||||
await commandRunner.run(<String>['get']);
|
await commandRunner.run(<String>['get']);
|
||||||
@ -60,7 +60,7 @@ void main() {
|
|||||||
..createSync(recursive: true)
|
..createSync(recursive: true)
|
||||||
..writeAsBytesSync(<int>[0]);
|
..writeAsBytesSync(<int>[0]);
|
||||||
|
|
||||||
final PackagesGetCommand command = PackagesGetCommand('get', false);
|
final PackagesGetCommand command = PackagesGetCommand('get', '', PubContext.pubGet);
|
||||||
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
|
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
|
||||||
|
|
||||||
await commandRunner.run(<String>['get']);
|
await commandRunner.run(<String>['get']);
|
||||||
@ -81,7 +81,7 @@ void main() {
|
|||||||
final Directory targetDirectory = fileSystem.currentDirectory.childDirectory('target');
|
final Directory targetDirectory = fileSystem.currentDirectory.childDirectory('target');
|
||||||
targetDirectory.childFile('pubspec.yaml').createSync();
|
targetDirectory.childFile('pubspec.yaml').createSync();
|
||||||
|
|
||||||
final PackagesGetCommand command = PackagesGetCommand('get', false);
|
final PackagesGetCommand command = PackagesGetCommand('get', '', PubContext.pubGet);
|
||||||
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
|
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
|
||||||
|
|
||||||
await commandRunner.run(<String>['get', targetDirectory.path]);
|
await commandRunner.run(<String>['get', targetDirectory.path]);
|
||||||
@ -98,7 +98,7 @@ void main() {
|
|||||||
fileSystem.currentDirectory.childFile('pubspec.yaml').createSync();
|
fileSystem.currentDirectory.childFile('pubspec.yaml').createSync();
|
||||||
fileSystem.currentDirectory.childDirectory('example').createSync(recursive: true);
|
fileSystem.currentDirectory.childDirectory('example').createSync(recursive: true);
|
||||||
|
|
||||||
final PackagesGetCommand command = PackagesGetCommand('get', false);
|
final PackagesGetCommand command = PackagesGetCommand('get', '', PubContext.pubGet);
|
||||||
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
|
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
|
||||||
|
|
||||||
await commandRunner.run(<String>['get']);
|
await commandRunner.run(<String>['get']);
|
||||||
@ -115,7 +115,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('pub get throws error on missing directory', () async {
|
testUsingContext('pub get throws error on missing directory', () async {
|
||||||
final PackagesGetCommand command = PackagesGetCommand('get', false);
|
final PackagesGetCommand command = PackagesGetCommand('get', '', PubContext.pubGet);
|
||||||
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
|
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -159,7 +159,7 @@ void main() {
|
|||||||
'''
|
'''
|
||||||
);
|
);
|
||||||
|
|
||||||
final PackagesGetCommand command = PackagesGetCommand('get', false);
|
final PackagesGetCommand command = PackagesGetCommand('get', '', PubContext.pubGet);
|
||||||
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
|
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
|
||||||
|
|
||||||
await commandRunner.run(<String>['get']);
|
await commandRunner.run(<String>['get']);
|
||||||
@ -183,23 +183,21 @@ class FakePub extends Fake implements Pub {
|
|||||||
final FileSystem fileSystem;
|
final FileSystem fileSystem;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> get({
|
Future<void> interactively(
|
||||||
|
List<String> arguments, {
|
||||||
|
FlutterProject? project,
|
||||||
required PubContext context,
|
required PubContext context,
|
||||||
required FlutterProject project,
|
required String command,
|
||||||
bool skipIfAbsent = false,
|
bool touchesPackageConfig = false,
|
||||||
bool upgrade = false,
|
|
||||||
bool offline = false,
|
|
||||||
bool generateSyntheticPackage = false,
|
bool generateSyntheticPackage = false,
|
||||||
bool generateSyntheticPackageForExample = false,
|
|
||||||
String? flutterRootOverride,
|
|
||||||
bool checkUpToDate = false,
|
|
||||||
bool shouldSkipThirdPartyGenerator = true,
|
|
||||||
bool printProgress = true,
|
bool printProgress = true,
|
||||||
}) async {
|
}) async {
|
||||||
|
if (project != null) {
|
||||||
fileSystem.directory(project.directory)
|
fileSystem.directory(project.directory)
|
||||||
.childDirectory('.dart_tool')
|
.childDirectory('.dart_tool')
|
||||||
.childFile('package_config.json')
|
.childFile('package_config.json')
|
||||||
..createSync(recursive: true)
|
..createSync(recursive: true)
|
||||||
..writeAsStringSync('{"configVersion":2,"packages":[]}');
|
..writeAsStringSync('{"configVersion":2,"packages":[]}');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,6 @@ class FakePub extends Fake implements Pub {
|
|||||||
Future<void> get({
|
Future<void> get({
|
||||||
required PubContext context,
|
required PubContext context,
|
||||||
required FlutterProject project,
|
required FlutterProject project,
|
||||||
bool skipIfAbsent = false,
|
|
||||||
bool upgrade = false,
|
bool upgrade = false,
|
||||||
bool offline = false,
|
bool offline = false,
|
||||||
bool generateSyntheticPackage = false,
|
bool generateSyntheticPackage = false,
|
||||||
|
@ -72,6 +72,7 @@ void main() {
|
|||||||
'packages',
|
'packages',
|
||||||
verb,
|
verb,
|
||||||
...?args,
|
...?args,
|
||||||
|
'--directory',
|
||||||
projectPath,
|
projectPath,
|
||||||
]);
|
]);
|
||||||
return command;
|
return command;
|
||||||
|
@ -1208,7 +1208,6 @@ class FakePub extends Fake implements Pub {
|
|||||||
Future<void> get({
|
Future<void> get({
|
||||||
PubContext? context,
|
PubContext? context,
|
||||||
required FlutterProject project,
|
required FlutterProject project,
|
||||||
bool skipIfAbsent = false,
|
|
||||||
bool upgrade = false,
|
bool upgrade = false,
|
||||||
bool offline = false,
|
bool offline = false,
|
||||||
bool generateSyntheticPackage = false,
|
bool generateSyntheticPackage = false,
|
||||||
|
@ -557,7 +557,7 @@ exit code: 66
|
|||||||
),
|
),
|
||||||
throwsA(isA<ToolExit>().having((ToolExit error) => error.message, 'message', toolExitMessage)),
|
throwsA(isA<ToolExit>().having((ToolExit error) => error.message, 'message', toolExitMessage)),
|
||||||
);
|
);
|
||||||
expect(logger.statusText, 'Running "flutter pub get" in /...\n');
|
expect(logger.statusText, isEmpty);
|
||||||
expect(
|
expect(
|
||||||
mockStdio.stdout.writes.map(utf8.decode),
|
mockStdio.stdout.writes.map(utf8.decode),
|
||||||
<String>[
|
<String>[
|
||||||
@ -634,9 +634,7 @@ exit code: 66
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(logger.statusText,
|
expect(logger.statusText, isEmpty);
|
||||||
'Running "flutter pub get" in /...\n'
|
|
||||||
);
|
|
||||||
expect(logger.errorText, isEmpty);
|
expect(logger.errorText, isEmpty);
|
||||||
expect(processManager, hasNoRemainingExpectations);
|
expect(processManager, hasNoRemainingExpectations);
|
||||||
});
|
});
|
||||||
@ -1074,7 +1072,6 @@ exit code: 66
|
|||||||
context: PubContext.flutterTests,
|
context: PubContext.flutterTests,
|
||||||
); // pub sets date of .packages to 2002
|
); // pub sets date of .packages to 2002
|
||||||
|
|
||||||
expect(logger.statusText, 'Running "flutter pub get" in /...\n');
|
|
||||||
expect(logger.errorText, isEmpty);
|
expect(logger.errorText, isEmpty);
|
||||||
expect(fileSystem.file('pubspec.yaml').lastModifiedSync(), DateTime(2001)); // because nothing should touch it
|
expect(fileSystem.file('pubspec.yaml').lastModifiedSync(), DateTime(2001)); // because nothing should touch it
|
||||||
logger.clear();
|
logger.clear();
|
||||||
@ -1089,7 +1086,7 @@ exit code: 66
|
|||||||
context: PubContext.flutterTests,
|
context: PubContext.flutterTests,
|
||||||
); // pub does nothing
|
); // pub does nothing
|
||||||
|
|
||||||
expect(logger.statusText, 'Running "flutter pub get" in /...\n');
|
expect(logger.statusText, isEmpty);
|
||||||
expect(logger.errorText, isEmpty);
|
expect(logger.errorText, isEmpty);
|
||||||
expect(fileSystem.file('pubspec.yaml').lastModifiedSync(), DateTime(2001)); // because nothing should touch it
|
expect(fileSystem.file('pubspec.yaml').lastModifiedSync(), DateTime(2001)); // because nothing should touch it
|
||||||
logger.clear();
|
logger.clear();
|
||||||
|
@ -951,7 +951,6 @@ class FakePub extends Fake implements Pub {
|
|||||||
Future<void> get({
|
Future<void> get({
|
||||||
required PubContext context,
|
required PubContext context,
|
||||||
required FlutterProject project,
|
required FlutterProject project,
|
||||||
bool skipIfAbsent = false,
|
|
||||||
bool upgrade = false,
|
bool upgrade = false,
|
||||||
bool offline = false,
|
bool offline = false,
|
||||||
String? flutterRootOverride,
|
String? flutterRootOverride,
|
||||||
|
@ -110,15 +110,8 @@ class FakeCommand {
|
|||||||
Map<String, String>? environment,
|
Map<String, String>? environment,
|
||||||
Encoding? encoding,
|
Encoding? encoding,
|
||||||
) {
|
) {
|
||||||
expect(command.length, this.command.length);
|
final List<dynamic> matchers = this.command.map((Pattern x) => x is String ? x : matches(x)).toList();
|
||||||
for(int i = 0; i < command.length; i++) {
|
expect(command, matchers);
|
||||||
final Pattern expected = this.command[i];
|
|
||||||
if (expected is String) {
|
|
||||||
expect(command[i], expected);
|
|
||||||
} else {
|
|
||||||
expect(command[i], matches(this.command[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.workingDirectory != null) {
|
if (this.workingDirectory != null) {
|
||||||
expect(this.workingDirectory, workingDirectory);
|
expect(this.workingDirectory, workingDirectory);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:flutter_tools/src/base/io.dart';
|
|
||||||
import 'package:flutter_tools/src/dart/pub.dart';
|
import 'package:flutter_tools/src/dart/pub.dart';
|
||||||
import 'package:flutter_tools/src/project.dart';
|
import 'package:flutter_tools/src/project.dart';
|
||||||
|
|
||||||
@ -21,7 +20,6 @@ class ThrowingPub implements Pub {
|
|||||||
Future<void> get({
|
Future<void> get({
|
||||||
PubContext? context,
|
PubContext? context,
|
||||||
required FlutterProject project,
|
required FlutterProject project,
|
||||||
bool skipIfAbsent = false,
|
|
||||||
bool upgrade = false,
|
bool upgrade = false,
|
||||||
bool offline = false,
|
bool offline = false,
|
||||||
bool checkLastModified = true,
|
bool checkLastModified = true,
|
||||||
@ -39,10 +37,12 @@ class ThrowingPub implements Pub {
|
|||||||
@override
|
@override
|
||||||
Future<void> interactively(
|
Future<void> interactively(
|
||||||
List<String> arguments, {
|
List<String> arguments, {
|
||||||
String? directory,
|
FlutterProject? project,
|
||||||
required Stdio stdio,
|
required PubContext context,
|
||||||
|
required String command,
|
||||||
bool touchesPackageConfig = false,
|
bool touchesPackageConfig = false,
|
||||||
bool generateSyntheticPackage = false,
|
bool generateSyntheticPackage = false,
|
||||||
|
bool printProgress = true,
|
||||||
}) {
|
}) {
|
||||||
throw UnsupportedError('Attempted to invoke pub during test.');
|
throw UnsupportedError('Attempted to invoke pub during test.');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user