Commit 4678c120 authored by Devon Carew's avatar Devon Carew

find all repo packages (#3368)

* find all repo packages

* .dartignore
parent c4ae13ed
...@@ -457,7 +457,7 @@ class ItemGalleryBox extends StatelessWidget { ...@@ -457,7 +457,7 @@ class ItemGalleryBox extends StatelessWidget {
child: new Column( child: new Column(
children: <Widget>[ children: <Widget>[
new Flexible( new Flexible(
child: new TabBarView( child: new TabBarView<String>(
children: tabNames.map((String tabName) { children: tabNames.map((String tabName) {
return new Container( return new Container(
key: new Key("Tab $index - $tabName"), key: new Key("Tab $index - $tabName"),
......
name: complex_layout name: complex_layout
description: A new flutter project. description: A new flutter project.
dependencies: dependencies:
flutter: flutter:
path: ../../../packages/flutter path: ../../../packages/flutter
flutter_driver: flutter_driver:
path: ../../../packages/flutter_driver path: ../../../packages/flutter_driver
flutter_gallery_assets: '0.0.14' flutter_gallery_assets: '0.0.15'
dev_dependencies:
flutter_test:
path: ../../../packages/flutter_test
...@@ -13,13 +13,13 @@ import 'package:flutter/widgets.dart'; ...@@ -13,13 +13,13 @@ import 'package:flutter/widgets.dart';
final Random random = new Random(); final Random random = new Random();
Future<String> handleGetRandom(String json) async { Future<String> handleGetRandom(String json) async {
Map message = JSON.decode(json); Map<String, dynamic> message = JSON.decode(json);
double min = message['min'].toDouble(); double min = message['min'].toDouble();
double max = message['max'].toDouble(); double max = message['max'].toDouble();
double value = (random.nextDouble() * (max - min)) + min; double value = (random.nextDouble() * (max - min)) + min;
Map reply = {'value': value}; Map<String, double> reply = <String, double>{'value': value};
return JSON.encode(reply); return JSON.encode(reply);
} }
...@@ -51,13 +51,13 @@ class _HelloAndroidState extends State<HelloAndroid> { ...@@ -51,13 +51,13 @@ class _HelloAndroidState extends State<HelloAndroid> {
} }
void _getLocation() { void _getLocation() {
Map message = {'provider': 'network'}; Map<String, String> message = <String, String>{'provider': 'network'};
HostMessages.sendToHost('getLocation', JSON.encode(message)) HostMessages.sendToHost('getLocation', JSON.encode(message))
.then(_onReceivedLocation); .then(_onReceivedLocation);
} }
void _onReceivedLocation(String json) { void _onReceivedLocation(String json) {
Map reply = JSON.decode(json); Map<String, double> reply = JSON.decode(json);
setState(() { setState(() {
_latitude = reply['latitude']; _latitude = reply['latitude'];
_longitude = reply['longitude']; _longitude = reply['longitude'];
......
name: gradle name: gradle
dependencies: dependencies:
flutter: flutter:
path: ../../../../../packages/flutter path: ../../../../../packages/flutter
dev_dependencies:
flutter_test:
path: ../../../../../packages/flutter_test
...@@ -89,18 +89,6 @@ void _addPackage(String directoryPath, List<String> dartFiles, Set<String> pubSp ...@@ -89,18 +89,6 @@ void _addPackage(String directoryPath, List<String> dartFiles, Set<String> pubSp
pubSpecDirectories.add(directoryPath); pubSpecDirectories.add(directoryPath);
} }
/// Adds all packages in [subPath], assuming a flat directory structure, i.e.
/// each direct child of [subPath] is a plain Dart package.
void _addFlatPackageList(String subPath, List<String> dartFiles, Set<String> pubSpecDirectories) {
Directory subdirectory = new Directory(path.join(ArtifactStore.flutterRoot, subPath));
if (subdirectory.existsSync()) {
for (FileSystemEntity entry in subdirectory.listSync()) {
if (entry is Directory)
_addPackage(entry.path, dartFiles, pubSpecDirectories);
}
}
}
class FileChanged { } class FileChanged { }
class AnalyzeCommand extends FlutterCommand { class AnalyzeCommand extends FlutterCommand {
...@@ -199,8 +187,8 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -199,8 +187,8 @@ class AnalyzeCommand extends FlutterCommand {
//dev/manual_tests/*/ as package //dev/manual_tests/*/ as package
//dev/manual_tests/*/ as files //dev/manual_tests/*/ as files
_addFlatPackageList('packages', dartFiles, pubSpecDirectories); for (Directory dir in runner.getRepoPackages())
_addFlatPackageList('examples', dartFiles, pubSpecDirectories); _addPackage(dir.path, dartFiles, pubSpecDirectories);
Directory subdirectory; Directory subdirectory;
...@@ -235,7 +223,6 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -235,7 +223,6 @@ class AnalyzeCommand extends FlutterCommand {
if (foundOne) if (foundOne)
pubSpecDirectories.add(subdirectory.path); pubSpecDirectories.add(subdirectory.path);
} }
} }
dartFiles = dartFiles.map((String directory) => path.normalize(path.absolute(directory))).toSet().toList(); dartFiles = dartFiles.map((String directory) => path.normalize(path.absolute(directory))).toSet().toList();
...@@ -453,12 +440,7 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -453,12 +440,7 @@ class AnalyzeCommand extends FlutterCommand {
List<String> directories; List<String> directories;
if (argResults['flutter-repo']) { if (argResults['flutter-repo']) {
String root = path.absolute(ArtifactStore.flutterRoot); directories = runner.getRepoPackages().map((Directory dir) => dir.path).toList();
directories = <String>[];
directories.addAll(_gatherProjectPaths(path.join(root, 'examples')));
directories.addAll(_gatherProjectPaths(path.join(root, 'packages')));
directories.addAll(_gatherProjectPaths(path.join(root, 'dev')));
printStatus('Analyzing Flutter repository (${directories.length} projects).'); printStatus('Analyzing Flutter repository (${directories.length} projects).');
for (String projectPath in directories) for (String projectPath in directories)
printTrace(' ${path.relative(projectPath)}'); printTrace(' ${path.relative(projectPath)}');
...@@ -551,17 +533,6 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -551,17 +533,6 @@ class AnalyzeCommand extends FlutterCommand {
return false; return false;
} }
List<String> _gatherProjectPaths(String rootPath) {
if (FileSystemEntity.isFileSync(path.join(rootPath, 'pubspec.yaml')))
return <String>[rootPath];
return new Directory(rootPath)
.listSync(followLinks: false)
.expand((FileSystemEntity entity) {
return entity is Directory ? _gatherProjectPaths(entity.path) : <String>[];
});
}
} }
class PackageDependency { class PackageDependency {
......
...@@ -5,25 +5,10 @@ ...@@ -5,25 +5,10 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import '../artifacts.dart';
import '../dart/pub.dart'; import '../dart/pub.dart';
import '../globals.dart'; import '../globals.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
/// Return the total number of projects run; throws the exit code on error.
Future<int> _runPub(Directory directory, { bool upgrade: false }) async {
int updateCount = 0;
for (FileSystemEntity dir in directory.listSync()) {
if (dir is Directory && FileSystemEntity.isFileSync(dir.path + Platform.pathSeparator + 'pubspec.yaml')) {
updateCount++;
int code = await pubGet(directory: dir.path, upgrade: upgrade, checkLastModified: false);
if (code != 0)
throw code;
}
}
return updateCount;
}
class UpdatePackagesCommand extends FlutterCommand { class UpdatePackagesCommand extends FlutterCommand {
UpdatePackagesCommand({ this.hidden: false }) { UpdatePackagesCommand({ this.hidden: false }) {
argParser.addFlag( argParser.addFlag(
...@@ -52,10 +37,12 @@ class UpdatePackagesCommand extends FlutterCommand { ...@@ -52,10 +37,12 @@ class UpdatePackagesCommand extends FlutterCommand {
int count = 0; int count = 0;
bool upgrade = argResults['upgrade']; bool upgrade = argResults['upgrade'];
count += await _runPub(new Directory("${ArtifactStore.flutterRoot}/packages"), upgrade: upgrade); for (Directory dir in runner.getRepoPackages()) {
count += await _runPub(new Directory("${ArtifactStore.flutterRoot}/examples"), upgrade: upgrade); int code = await pubGet(directory: dir.path, upgrade: upgrade, checkLastModified: false);
count += await _runPub(new Directory("${ArtifactStore.flutterRoot}/dev"), upgrade: upgrade); if (code != 0)
count += await _runPub(new Directory("${ArtifactStore.flutterRoot}/dev/benchmarks"), upgrade: upgrade); throw code;
count++;
}
double seconds = timer.elapsedMilliseconds / 1000.0; double seconds = timer.elapsedMilliseconds / 1000.0;
printStatus('\nRan \'pub\' $count time${count == 1 ? "" : "s"} in ${seconds.toStringAsFixed(1)}s.'); printStatus('\nRan \'pub\' $count time${count == 1 ? "" : "s"} in ${seconds.toStringAsFixed(1)}s.');
......
...@@ -390,4 +390,25 @@ class FlutterCommandRunner extends CommandRunner { ...@@ -390,4 +390,25 @@ class FlutterCommandRunner extends CommandRunner {
if (ArtifactStore.flutterRoot == null) if (ArtifactStore.flutterRoot == null)
ArtifactStore.flutterRoot = _defaultFlutterRoot; ArtifactStore.flutterRoot = _defaultFlutterRoot;
} }
/// Get all pub packages in the Flutter repo.
List<Directory> getRepoPackages() {
return _gatherProjectPaths(path.absolute(ArtifactStore.flutterRoot))
.map((String dir) => new Directory(dir))
.toList();
}
static List<String> _gatherProjectPaths(String rootPath) {
if (FileSystemEntity.isFileSync(path.join(rootPath, '.dartignore')))
return <String>[];
if (FileSystemEntity.isFileSync(path.join(rootPath, 'pubspec.yaml')))
return <String>[rootPath];
return new Directory(rootPath)
.listSync(followLinks: false)
.expand((FileSystemEntity entity) {
return entity is Directory ? _gatherProjectPaths(entity.path) : <String>[];
});
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment