complain on missing entries in flutter.yaml (#3731)

* complain on missing entries in flutter.yaml

* change to a hard failure
This commit is contained in:
Devon Carew 2016-05-04 12:33:34 -07:00
parent 04e892a457
commit f34d31717c
4 changed files with 39 additions and 16 deletions

View file

@ -48,7 +48,7 @@ export PATH="$DART_SDK_PATH/bin:$PATH"
set +e
if [ $FLUTTER_DEV ]; then
"$DART" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH" "$@"
"$DART" --packages="$FLUTTER_TOOLS_DIR/.packages" -c "$SCRIPT_PATH" "$@"
else
"$DART" "$SNAPSHOT_PATH" "$@"
fi

View file

@ -313,6 +313,9 @@ class AndroidDevice extends Device {
includeRobotoFonts: false
);
if (localBundlePath == null)
return new LaunchResult.failed();
printTrace('Starting bundle for $this.');
return startBundle(

View file

@ -504,6 +504,9 @@ Future<int> buildAndroid(
mainPath: findMainDartFile(target),
precompiledSnapshot: isAotBuildMode(buildMode),
includeRobotoFonts: false);
if (flxPath == null)
return 1;
}
// Build an AOT snapshot if needed.

View file

@ -50,6 +50,12 @@ class _Asset {
final String source;
File get assetFile {
return new File(source != null ? '$base/$source' : '$base/$relativePath');
}
bool get assetFileExists => assetFile.existsSync();
/// The delta between what the assetEntry is and the relativePath (e.g.,
/// packages/material_gallery).
String get symbolicPrefix {
@ -95,6 +101,8 @@ List<_Asset> _getMaterialAssets(String fontSet) {
/// Given an assetBase location and a flutter.yaml manifest, return a map of
/// assets to asset variants.
///
/// Returns `null` on missing assets.
Map<_Asset, List<_Asset>> _parseAssets(
PackageMap packageMap,
Map<String, dynamic> manifestDescriptor,
@ -113,6 +121,11 @@ Map<_Asset, List<_Asset>> _parseAssets(
for (String asset in manifestDescriptor['assets']) {
_Asset baseAsset = _resolveAsset(packageMap, assetBase, asset);
if (!baseAsset.assetFileExists) {
printError('Error: unable to locate asset entry in flutter.yaml: "$asset".');
return null;
}
List<_Asset> variants = <_Asset>[];
result[baseAsset] = variants;
@ -196,22 +209,24 @@ Future<int> _validateManifest(Object manifest) async {
Schema schema = await Schema.createSchemaFromUrl('file://$schemaPath');
Validator validator = new Validator(schema);
if (validator.validate(manifest))
if (validator.validate(manifest)) {
return 0;
} else {
if (validator.errors.length == 1) {
printError('Error in flutter.yaml: ${validator.errors.first}');
} else {
printError('Error in flutter.yaml:');
printError(' ' + validator.errors.join('\n '));
}
printError('Error in flutter.yaml:');
printError(validator.errors.join('\n'));
return 1;
return 1;
}
}
/// Create a [ZipEntry] from the given [_Asset]; the asset must exist.
ZipEntry _createAssetEntry(_Asset asset) {
String source = asset.source ?? asset.relativePath;
File file = new File('${asset.base}/$source');
if (!file.existsSync()) {
printError('Cannot find asset "$source" in directory "${path.absolute(asset.base)}".');
return null;
}
return new ZipEntry.fromFile(asset.assetEntry, file);
assert(asset.assetFileExists);
return new ZipEntry.fromFile(asset.assetEntry, asset.assetFile);
}
ZipEntry _createAssetManifest(Map<_Asset, List<_Asset>> assetVariants) {
@ -242,6 +257,8 @@ ZipEntry _createFontManifest(Map<String, dynamic> manifestDescriptor,
}
/// Build the flx in the build/ directory and return `localBundlePath` on success.
///
/// Return `null` on failure.
Future<String> buildFlx(
Toolchain toolchain, {
String mainPath: defaultMainPath,
@ -259,10 +276,7 @@ Future<String> buildFlx(
precompiledSnapshot: precompiledSnapshot,
includeRobotoFonts: includeRobotoFonts
);
if (result == 0)
return localBundlePath;
else
throw result;
return result == 0 ? localBundlePath : null;
}
/// The result from [buildInTempDir]. Note that this object should be disposed after use.
@ -349,6 +363,9 @@ Future<int> assemble({
excludeDirs: <String>[workingDirPath, path.join(assetBasePath, 'build')]
);
if (assetVariants == null)
return 1;
final bool usesMaterialDesign = manifestDescriptor != null &&
manifestDescriptor['uses-material-design'] == true;