Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
3cbbbf06
Commit
3cbbbf06
authored
Sep 26, 2017
by
Sarah Zakarias
Committed by
GitHub
Sep 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow empty pubspec file when building asset bundle (#12269)
parent
65e3df88
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
5 deletions
+40
-5
asset.dart
packages/flutter_tools/lib/src/asset.dart
+8
-2
flutter_manifest.dart
packages/flutter_tools/lib/src/flutter_manifest.dart
+5
-3
asset_bundle_test.dart
packages/flutter_tools/test/asset_bundle_test.dart
+16
-0
flutter_manifest_test.dart
packages/flutter_tools/test/flutter_manifest_test.dart
+11
-0
No files found.
packages/flutter_tools/lib/src/asset.dart
View file @
3cbbbf06
...
@@ -75,13 +75,19 @@ class AssetBundle {
...
@@ -75,13 +75,19 @@ class AssetBundle {
FlutterManifest
flutterManifest
;
FlutterManifest
flutterManifest
;
try
{
try
{
flutterManifest
=
await
FlutterManifest
.
createFromPath
(
manifestPath
);
flutterManifest
=
await
FlutterManifest
.
createFromPath
(
manifestPath
);
if
(
flutterManifest
==
null
)
return
1
;
}
catch
(
e
)
{
}
catch
(
e
)
{
printStatus
(
'Error detected in pubspec.yaml:'
,
emphasis:
true
);
printStatus
(
'Error detected in pubspec.yaml:'
,
emphasis:
true
);
printError
(
'
$e
'
);
printError
(
'
$e
'
);
return
1
;
return
1
;
}
}
if
(
flutterManifest
==
null
)
return
1
;
if
(
flutterManifest
.
isEmpty
)
{
entries
[
_kAssetManifestJson
]
=
new
DevFSStringContent
(
'{}'
);
return
0
;
}
final
String
assetBasePath
=
fs
.
path
.
dirname
(
fs
.
path
.
absolute
(
manifestPath
));
final
String
assetBasePath
=
fs
.
path
.
dirname
(
fs
.
path
.
absolute
(
manifestPath
));
_lastBuildTimestamp
=
new
DateTime
.
now
();
_lastBuildTimestamp
=
new
DateTime
.
now
();
...
...
packages/flutter_tools/lib/src/flutter_manifest.dart
View file @
3cbbbf06
...
@@ -26,10 +26,10 @@ class FlutterManifest {
...
@@ -26,10 +26,10 @@ class FlutterManifest {
static
Future
<
FlutterManifest
>
_createFromYaml
(
Object
yamlDocument
)
async
{
static
Future
<
FlutterManifest
>
_createFromYaml
(
Object
yamlDocument
)
async
{
final
FlutterManifest
pubspec
=
new
FlutterManifest
.
_
();
final
FlutterManifest
pubspec
=
new
FlutterManifest
.
_
();
if
(
yamlDocument
==
null
||
!
await
_validate
(
yamlDocument
))
if
(
yamlDocument
!=
null
&&
!
await
_validate
(
yamlDocument
))
return
null
;
return
null
;
pubspec
.
_descriptor
=
yamlDocument
;
pubspec
.
_descriptor
=
yamlDocument
??
<
String
,
dynamic
>{}
;
pubspec
.
_flutterDescriptor
=
pubspec
.
_descriptor
[
'flutter'
]
??
<
String
,
dynamic
>{};
pubspec
.
_flutterDescriptor
=
pubspec
.
_descriptor
[
'flutter'
]
??
<
String
,
dynamic
>{};
return
pubspec
;
return
pubspec
;
}
}
...
@@ -40,7 +40,9 @@ class FlutterManifest {
...
@@ -40,7 +40,9 @@ class FlutterManifest {
/// A map representation of the `flutter` section in the `pubspec.yaml` file.
/// A map representation of the `flutter` section in the `pubspec.yaml` file.
Map
<
String
,
dynamic
>
_flutterDescriptor
;
Map
<
String
,
dynamic
>
_flutterDescriptor
;
String
get
appName
=>
_descriptor
[
'name'
];
bool
get
isEmpty
=>
_descriptor
.
isEmpty
;
String
get
appName
=>
_descriptor
[
'name'
]
??
''
;
bool
get
usesMaterialDesign
{
bool
get
usesMaterialDesign
{
return
_flutterDescriptor
[
'uses-material-design'
]
??
false
;
return
_flutterDescriptor
[
'uses-material-design'
]
??
false
;
...
...
packages/flutter_tools/test/asset_bundle_test.dart
View file @
3cbbbf06
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
import
'dart:convert'
;
import
'dart:convert'
;
import
'package:file/file.dart'
;
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/asset.dart'
;
import
'package:flutter_tools/src/asset.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
...
@@ -80,6 +81,21 @@ void main() {
...
@@ -80,6 +81,21 @@ void main() {
expect
(
await
ab
.
build
(),
0
);
expect
(
await
ab
.
build
(),
0
);
expect
(
ab
.
entries
.
length
,
greaterThan
(
0
));
expect
(
ab
.
entries
.
length
,
greaterThan
(
0
));
});
});
testUsingContext
(
'empty pubspec'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
)
..
createSync
()
..
writeAsStringSync
(
''
);
final
AssetBundle
bundle
=
new
AssetBundle
();
await
bundle
.
build
(
manifestPath:
'pubspec.yaml'
);
expect
(
bundle
.
entries
.
length
,
1
);
final
String
expectedAssetManifest
=
'{}'
;
expect
(
UTF8
.
decode
(
await
bundle
.
entries
[
'AssetManifest.json'
].
contentsAsBytes
()),
expectedAssetManifest
,
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
new
MemoryFileSystem
(),});
});
});
}
}
packages/flutter_tools/test/flutter_manifest_test.dart
View file @
3cbbbf06
...
@@ -16,6 +16,16 @@ void main() {
...
@@ -16,6 +16,16 @@ void main() {
});
});
group
(
'FlutterManifest'
,
()
{
group
(
'FlutterManifest'
,
()
{
testUsingContext
(
'is empty when the pubspec.yaml file is empty'
,
()
async
{
final
FlutterManifest
flutterManifest
=
await
FlutterManifest
.
createFromString
(
''
);
expect
(
flutterManifest
.
isEmpty
,
true
);
expect
(
flutterManifest
.
appName
,
''
);
expect
(
flutterManifest
.
usesMaterialDesign
,
false
);
expect
(
flutterManifest
.
fontsDescriptor
,
isEmpty
);
expect
(
flutterManifest
.
fonts
,
isEmpty
);
expect
(
flutterManifest
.
assets
,
isEmpty
);
});
test
(
'has no fonts or assets when the "flutter" section is empty'
,
()
async
{
test
(
'has no fonts or assets when the "flutter" section is empty'
,
()
async
{
final
String
manifest
=
'''
final
String
manifest
=
'''
name: test
name: test
...
@@ -25,6 +35,7 @@ dependencies:
...
@@ -25,6 +35,7 @@ dependencies:
'''
;
'''
;
final
FlutterManifest
flutterManifest
=
await
FlutterManifest
.
createFromString
(
manifest
);
final
FlutterManifest
flutterManifest
=
await
FlutterManifest
.
createFromString
(
manifest
);
expect
(
flutterManifest
,
isNotNull
);
expect
(
flutterManifest
,
isNotNull
);
expect
(
flutterManifest
.
isEmpty
,
false
);
expect
(
flutterManifest
.
appName
,
'test'
);
expect
(
flutterManifest
.
appName
,
'test'
);
expect
(
flutterManifest
.
usesMaterialDesign
,
false
);
expect
(
flutterManifest
.
usesMaterialDesign
,
false
);
expect
(
flutterManifest
.
fontsDescriptor
,
isEmpty
);
expect
(
flutterManifest
.
fontsDescriptor
,
isEmpty
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment