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
ebf1ecc5
Commit
ebf1ecc5
authored
Mar 01, 2016
by
Devon Carew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
valdate project names in create
parent
9ce6bff5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
6 deletions
+43
-6
create.dart
packages/flutter_tools/lib/src/commands/create.dart
+43
-6
No files found.
packages/flutter_tools/lib/src/commands/create.dart
View file @
ebf1ecc5
...
...
@@ -76,7 +76,15 @@ class CreateCommand extends Command {
projectDir
=
new
Directory
(
argResults
.
rest
.
first
);
}
_renderTemplates
(
projectDir
,
flutterPackagesDirectory
,
String
dirPath
=
path
.
normalize
(
projectDir
.
absolute
.
path
);
String
projectName
=
_normalizeProjectName
(
path
.
basename
(
dirPath
));
if
(
_validateProjectName
(
projectName
)
!=
null
)
{
printError
(
_validateProjectName
(
projectName
));
return
1
;
}
_renderTemplates
(
projectName
,
dirPath
,
flutterPackagesDirectory
,
renderDriverTest:
argResults
[
'with-driver-test'
]);
if
(
argResults
[
'pub'
])
{
...
...
@@ -115,16 +123,14 @@ All done! In order to run your application, type:
return
0
;
}
void
_renderTemplates
(
Directory
projectDir
,
String
flutterPackagesDirectory
,
{
bool
renderDriverTest:
false
})
{
String
dirPath
=
path
.
normalize
(
projectDir
.
absolute
.
path
);
String
projectName
=
_normalizeProjectName
(
path
.
basename
(
dirPath
));
void
_renderTemplates
(
String
projectName
,
String
dirPath
,
String
flutterPackagesDirectory
,
{
bool
renderDriverTest:
false
})
{
String
projectIdentifier
=
_createProjectIdentifier
(
path
.
basename
(
dirPath
));
String
relativeFlutterPackagesDirectory
=
path
.
relative
(
flutterPackagesDirectory
,
from:
dirPath
);
printStatus
(
'Creating project
${path.basename(projectName)}
:'
);
projectDir
.
createSync
(
recursive:
true
);
new
Directory
(
dirPath
)
.
createSync
(
recursive:
true
);
Map
templateContext
=
<
String
,
dynamic
>{
'projectName'
:
projectName
,
...
...
@@ -164,3 +170,34 @@ String _createProjectIdentifier(String name) {
name
=
name
.
length
==
0
?
'untitled'
:
name
;
return
'com.yourcompany.
$name
'
;
}
final
Set
<
String
>
_packageDependencies
=
new
Set
<
String
>.
from
(<
String
>[
'args'
,
'async'
,
'collection'
,
'convert'
,
'flutter'
,
'html'
,
'intl'
,
'logging'
,
'matcher'
,
'mime'
,
'path'
,
'plugin'
,
'pool'
,
'test'
,
'utf'
,
'watcher'
,
'yaml'
]);
/// Return `null` if the project name is legal. Return a validation message if
/// we should disallow the project name.
String
_validateProjectName
(
String
projectName
)
{
if
(
_packageDependencies
.
contains
(
projectName
))
{
return
"Invalid project name: '
$projectName
' - this will conflict with Flutter "
"package dependencies."
;
}
return
null
;
}
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