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
d9d94b16
Commit
d9d94b16
authored
Mar 02, 2016
by
Devon Carew
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2328 from devoncarew/no_dashes
clean the project names used for flutter create
parents
0d498374
4c569195
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
13 deletions
+34
-13
utils.dart
packages/flutter_tools/lib/src/base/utils.dart
+15
-0
create.dart
packages/flutter_tools/lib/src/commands/create.dart
+15
-8
devices.dart
packages/flutter_tools/lib/src/commands/devices.dart
+1
-2
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+1
-1
AndroidManifest.xml.tmpl
...r_tools/templates/create/android/AndroidManifest.xml.tmpl
+1
-1
Info.plist.tmpl
packages/flutter_tools/templates/create/ios/Info.plist.tmpl
+1
-1
No files found.
packages/flutter_tools/lib/src/base/utils.dart
View file @
d9d94b16
...
...
@@ -13,6 +13,21 @@ String calculateSha(File file) {
return
CryptoUtils
.
bytesToHex
(
sha1
.
close
());
}
/// Convert `foo_bar` to `fooBar`.
String
camelCase
(
String
str
)
{
int
index
=
str
.
indexOf
(
'_'
);
while
(
index
!=
-
1
&&
index
<
str
.
length
-
2
)
{
str
=
str
.
substring
(
0
,
index
)
+
str
.
substring
(
index
+
1
,
index
+
2
).
toUpperCase
()
+
str
.
substring
(
index
+
2
);
index
=
str
.
indexOf
(
'_'
);
}
return
str
;
}
/// Return the plural of the given word (`cat(s)`).
String
pluralize
(
String
word
,
int
count
)
=>
count
==
1
?
word
:
word
+
's'
;
/// A class to maintain a list of items, fire events when items are added or
/// removed, and calculate a diff of changes when a new list of items is
/// available.
...
...
packages/flutter_tools/lib/src/commands/create.dart
View file @
d9d94b16
...
...
@@ -10,6 +10,7 @@ import 'package:path/path.dart' as path;
import
'../android/android.dart'
as
android
;
import
'../artifacts.dart'
;
import
'../base/utils.dart'
;
import
'../dart/pub.dart'
;
import
'../globals.dart'
;
import
'../template.dart'
;
...
...
@@ -87,8 +88,10 @@ class CreateCommand extends Command {
_renderTemplates
(
projectName
,
dirPath
,
flutterPackagesDirectory
,
renderDriverTest:
argResults
[
'with-driver-test'
]);
printStatus
(
''
);
if
(
argResults
[
'pub'
])
{
int
code
=
await
pubGet
(
directory:
projectDir
.
p
ath
);
int
code
=
await
pubGet
(
directory:
dirP
ath
);
if
(
code
!=
0
)
return
code
;
}
...
...
@@ -103,7 +106,7 @@ class CreateCommand extends Command {
printStatus
(
'''
All done! In order to run your application, type:
\$
cd
$
{projectDir.path}
\$
cd
$
dirPath
\$
flutter run
'''
);
}
else
{
...
...
@@ -116,7 +119,7 @@ All done! In order to run your application, type:
printStatus
(
''
);
printStatus
(
"After installing components, run 'flutter doctor' in order to "
"re-validate your setup."
);
printStatus
(
"When complete, type 'flutter run' from the '
$
{projectDir.path}
' "
printStatus
(
"When complete, type 'flutter run' from the '
$
dirPath
' "
"directory in order to launch your app."
);
}
...
...
@@ -125,7 +128,6 @@ All done! In order to run your application, type:
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)}
:'
);
...
...
@@ -134,7 +136,8 @@ All done! In order to run your application, type:
Map
templateContext
=
<
String
,
dynamic
>{
'projectName'
:
projectName
,
'projectIdentifier'
:
projectIdentifier
,
'androidIdentifier'
:
_createAndroidIdentifier
(
projectName
),
'iosIdentifier'
:
_createUTIIdentifier
(
projectName
),
'description'
:
description
,
'flutterPackagesDirectory'
:
relativeFlutterPackagesDirectory
,
'androidMinApiLevel'
:
android
.
minApiLevel
...
...
@@ -163,11 +166,15 @@ String _normalizeProjectName(String name) {
return
name
;
}
String
_createProjectIdentifier
(
String
name
)
{
String
_createAndroidIdentifier
(
String
name
)
{
return
'com.yourcompany.
${camelCase(name)}
'
;
}
String
_createUTIIdentifier
(
String
name
)
{
// Create a UTI (https://en.wikipedia.org/wiki/Uniform_Type_Identifier) from a base name
RegExp
disallowed
=
new
RegExp
(
r"[^a-zA-Z0-9\-.\u0080-\uffff]+"
);
name
=
name
.
replaceAll
(
disallowed
,
''
);
name
=
name
.
length
==
0
?
'untitled'
:
name
;
name
=
camelCase
(
name
)
.
replaceAll
(
disallowed
,
''
);
name
=
name
.
isEmpty
?
'untitled'
:
name
;
return
'com.yourcompany.
$name
'
;
}
...
...
packages/flutter_tools/lib/src/commands/devices.dart
View file @
d9d94b16
...
...
@@ -4,6 +4,7 @@
import
'dart:async'
;
import
'../base/utils.dart'
;
import
'../device.dart'
;
import
'../globals.dart'
;
import
'../runner/flutter_command.dart'
;
...
...
@@ -38,5 +39,3 @@ class DevicesCommand extends FlutterCommand {
return
0
;
}
}
String
pluralize
(
String
word
,
int
count
)
=>
count
==
1
?
word
:
word
+
's'
;
packages/flutter_tools/lib/src/commands/run.dart
View file @
d9d94b16
...
...
@@ -9,6 +9,7 @@ import 'package:path/path.dart' as path;
import
'../application_package.dart'
;
import
'../base/common.dart'
;
import
'../base/utils.dart'
;
import
'../build_configuration.dart'
;
import
'../dart/pub.dart'
;
import
'../device.dart'
;
...
...
@@ -17,7 +18,6 @@ import '../globals.dart';
import
'../runner/flutter_command.dart'
;
import
'../toolchain.dart'
;
import
'apk.dart'
;
import
'devices.dart'
;
import
'install.dart'
;
/// Given the value of the --target option, return the path of the Dart file
...
...
packages/flutter_tools/templates/create/android/AndroidManifest.xml.tmpl
View file @
d9d94b16
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="{{
project
Identifier}}"
package="{{
android
Identifier}}"
android:versionCode="1"
android:versionName="0.0.1">
...
...
packages/flutter_tools/templates/create/ios/Info.plist.tmpl
View file @
d9d94b16
...
...
@@ -7,7 +7,7 @@
<key>
CFBundleExecutable
</key>
<string>
Runner
</string>
<key>
CFBundleIdentifier
</key>
<string>
{{
project
Identifier}}
</string>
<string>
{{
ios
Identifier}}
</string>
<key>
CFBundleInfoDictionaryVersion
</key>
<string>
6.0
</string>
<key>
CFBundleName
</key>
...
...
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