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
c2b4ac9c
Commit
c2b4ac9c
authored
Mar 25, 2016
by
Jason Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate flutter.yaml against a JSON schema
parent
f5c3b75d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
3 deletions
+60
-3
flutter.yaml
examples/stocks/flutter.yaml
+0
-2
flx.dart
packages/flutter_tools/lib/src/flx.dart
+23
-1
pubspec.yaml
packages/flutter_tools/pubspec.yaml
+1
-0
flutter_yaml.json
packages/flutter_tools/schema/flutter_yaml.json
+36
-0
No files found.
examples/stocks/flutter.yaml
View file @
c2b4ac9c
name
:
stocks
version
:
0.0.2
update-url
:
http://localhost:9888/
uses-material-design
:
true
packages/flutter_tools/lib/src/flx.dart
View file @
c2b4ac9c
...
...
@@ -8,6 +8,7 @@ import 'dart:io';
import
'package:flx/bundle.dart'
;
import
'package:flx/signing.dart'
;
import
'package:json_schema/json_schema.dart'
;
import
'package:path/path.dart'
as
path
;
import
'package:yaml/yaml.dart'
;
...
...
@@ -108,6 +109,20 @@ dynamic _loadManifest(String manifestPath) {
return
loadYaml
(
manifestDescriptor
);
}
Future
<
int
>
_validateManifest
(
Object
manifest
)
async
{
String
schemaPath
=
path
.
join
(
path
.
absolute
(
ArtifactStore
.
flutterRoot
),
'packages'
,
'flutter_tools'
,
'schema'
,
'flutter_yaml.json'
);
Schema
schema
=
await
Schema
.
createSchemaFromUrl
(
'file://
$schemaPath
'
);
Validator
validator
=
new
Validator
(
schema
);
if
(
validator
.
validate
(
manifest
))
return
0
;
printError
(
'Error in flutter.yaml:'
);
printError
(
validator
.
errors
.
join
(
'
\n
'
));
return
1
;
}
ZipEntry
_createAssetEntry
(
_Asset
asset
)
{
String
source
=
asset
.
source
??
asset
.
key
;
File
file
=
new
File
(
'
${asset.base}
/
$source
'
);
...
...
@@ -184,7 +199,14 @@ Future<int> build(
String
workingDirPath:
defaultWorkingDirPath
,
bool
precompiledSnapshot:
false
})
async
{
Map
<
String
,
dynamic
>
manifestDescriptor
=
_loadManifest
(
manifestPath
);
Object
manifest
=
_loadManifest
(
manifestPath
);
if
(
manifest
!=
null
)
{
int
result
=
await
_validateManifest
(
manifest
);
if
(
result
!=
0
)
return
result
;
}
Map
<
String
,
dynamic
>
manifestDescriptor
=
manifest
;
String
assetBasePath
=
path
.
dirname
(
path
.
absolute
(
manifestPath
));
File
snapshotFile
;
...
...
packages/flutter_tools/pubspec.yaml
View file @
c2b4ac9c
...
...
@@ -14,6 +14,7 @@ dependencies:
crypto
:
^0.9.2
den_api
:
^0.1.0
file
:
^0.1.0
json_schema
:
^1.0.3
mustache4dart
:
^1.0.0
path
:
^1.3.0
pub_semver
:
^1.0.0
...
...
packages/flutter_tools/schema/flutter_yaml.json
0 → 100644
View file @
c2b4ac9c
{
"$schema"
:
"http://json-schema.org/draft-04/schema#"
,
"title"
:
"flutter.yaml"
,
"type"
:
"object"
,
"additionalProperties"
:
false
,
"properties"
:
{
"name"
:
{
"type"
:
"string"
},
"uses-material-design"
:
{
"type"
:
"boolean"
},
"assets"
:
{
"type"
:
"array"
,
"items"
:
{
"type"
:
"string"
}
},
"fonts"
:
{
"type"
:
"array"
,
"items"
:
{
"type"
:
"object"
,
"additionalProperties"
:
false
,
"properties"
:
{
"family"
:
{
"type"
:
"string"
},
"fonts"
:
{
"type"
:
"array"
,
"items"
:
{
"type"
:
"object"
,
"additionalProperties"
:
false
,
"properties"
:
{
"asset"
:
{
"type"
:
"string"
},
"weight"
:
{
"type"
:
"integer"
},
"style"
:
{
"enum"
:
[
"normal"
,
"italic"
]
}
}
}
}
}
}
}
}
}
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