find all repo packages (#3368)

* find all repo packages

* .dartignore
This commit is contained in:
Devon Carew 2016-04-15 20:25:57 -07:00
parent c4ae13ed22
commit 4678c12098
9 changed files with 46 additions and 57 deletions

0
bin/cache/.dartignore vendored Normal file
View file

View file

@ -457,7 +457,7 @@ class ItemGalleryBox extends StatelessWidget {
child: new Column(
children: <Widget>[
new Flexible(
child: new TabBarView(
child: new TabBarView<String>(
children: tabNames.map((String tabName) {
return new Container(
key: new Key("Tab $index - $tabName"),

View file

@ -1,8 +1,13 @@
name: complex_layout
description: A new flutter project.
dependencies:
flutter:
path: ../../../packages/flutter
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

0
dev/docs/.dartignore Normal file
View file

View file

@ -13,13 +13,13 @@ import 'package:flutter/widgets.dart';
final Random random = new Random();
Future<String> handleGetRandom(String json) async {
Map message = JSON.decode(json);
Map<String, dynamic> message = JSON.decode(json);
double min = message['min'].toDouble();
double max = message['max'].toDouble();
double value = (random.nextDouble() * (max - min)) + min;
Map reply = {'value': value};
Map<String, double> reply = <String, double>{'value': value};
return JSON.encode(reply);
}
@ -51,13 +51,13 @@ class _HelloAndroidState extends State<HelloAndroid> {
}
void _getLocation() {
Map message = {'provider': 'network'};
Map<String, String> message = <String, String>{'provider': 'network'};
HostMessages.sendToHost('getLocation', JSON.encode(message))
.then(_onReceivedLocation);
}
void _onReceivedLocation(String json) {
Map reply = JSON.decode(json);
Map<String, double> reply = JSON.decode(json);
setState(() {
_latitude = reply['latitude'];
_longitude = reply['longitude'];

View file

@ -1,4 +1,9 @@
name: gradle
dependencies:
flutter:
path: ../../../../../packages/flutter
dev_dependencies:
flutter_test:
path: ../../../../../packages/flutter_test

View file

@ -89,18 +89,6 @@ void _addPackage(String directoryPath, List<String> dartFiles, Set<String> pubSp
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 AnalyzeCommand extends FlutterCommand {
@ -199,8 +187,8 @@ class AnalyzeCommand extends FlutterCommand {
//dev/manual_tests/*/ as package
//dev/manual_tests/*/ as files
_addFlatPackageList('packages', dartFiles, pubSpecDirectories);
_addFlatPackageList('examples', dartFiles, pubSpecDirectories);
for (Directory dir in runner.getRepoPackages())
_addPackage(dir.path, dartFiles, pubSpecDirectories);
Directory subdirectory;
@ -235,7 +223,6 @@ class AnalyzeCommand extends FlutterCommand {
if (foundOne)
pubSpecDirectories.add(subdirectory.path);
}
}
dartFiles = dartFiles.map((String directory) => path.normalize(path.absolute(directory))).toSet().toList();
@ -453,12 +440,7 @@ class AnalyzeCommand extends FlutterCommand {
List<String> directories;
if (argResults['flutter-repo']) {
String root = path.absolute(ArtifactStore.flutterRoot);
directories = <String>[];
directories.addAll(_gatherProjectPaths(path.join(root, 'examples')));
directories.addAll(_gatherProjectPaths(path.join(root, 'packages')));
directories.addAll(_gatherProjectPaths(path.join(root, 'dev')));
directories = runner.getRepoPackages().map((Directory dir) => dir.path).toList();
printStatus('Analyzing Flutter repository (${directories.length} projects).');
for (String projectPath in directories)
printTrace(' ${path.relative(projectPath)}');
@ -551,17 +533,6 @@ class AnalyzeCommand extends FlutterCommand {
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 {

View file

@ -5,25 +5,10 @@
import 'dart:async';
import 'dart:io';
import '../artifacts.dart';
import '../dart/pub.dart';
import '../globals.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 {
UpdatePackagesCommand({ this.hidden: false }) {
argParser.addFlag(
@ -52,10 +37,12 @@ class UpdatePackagesCommand extends FlutterCommand {
int count = 0;
bool upgrade = argResults['upgrade'];
count += await _runPub(new Directory("${ArtifactStore.flutterRoot}/packages"), upgrade: upgrade);
count += await _runPub(new Directory("${ArtifactStore.flutterRoot}/examples"), upgrade: upgrade);
count += await _runPub(new Directory("${ArtifactStore.flutterRoot}/dev"), upgrade: upgrade);
count += await _runPub(new Directory("${ArtifactStore.flutterRoot}/dev/benchmarks"), upgrade: upgrade);
for (Directory dir in runner.getRepoPackages()) {
int code = await pubGet(directory: dir.path, upgrade: upgrade, checkLastModified: false);
if (code != 0)
throw code;
count++;
}
double seconds = timer.elapsedMilliseconds / 1000.0;
printStatus('\nRan \'pub\' $count time${count == 1 ? "" : "s"} in ${seconds.toStringAsFixed(1)}s.');

View file

@ -390,4 +390,25 @@ class FlutterCommandRunner extends CommandRunner {
if (ArtifactStore.flutterRoot == null)
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>[];
});
}
}