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
48915069
Commit
48915069
authored
Jul 07, 2017
by
Devon Carew
Committed by
GitHub
Jul 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a --machine mode to flutter config (#11112)
* add a --machine mode to flutter config * review feedback
parent
40a65e1f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
10 deletions
+64
-10
executable.dart
packages/flutter_tools/lib/executable.dart
+1
-1
android_studio.dart
packages/flutter_tools/lib/src/android/android_studio.dart
+3
-1
analyze.dart
packages/flutter_tools/lib/src/commands/analyze.dart
+1
-1
config.dart
packages/flutter_tools/lib/src/commands/config.dart
+27
-5
config_test.dart
packages/flutter_tools/test/config_test.dart
+32
-2
No files found.
packages/flutter_tools/lib/executable.dart
View file @
48915069
...
...
@@ -68,7 +68,7 @@ Future<Null> main(List<String> args) async {
new
AnalyzeCommand
(
verboseHelp:
verboseHelp
),
new
BuildCommand
(
verboseHelp:
verboseHelp
),
new
ChannelCommand
(),
new
ConfigCommand
(),
new
ConfigCommand
(
verboseHelp:
verboseHelp
),
new
CreateCommand
(),
new
DaemonCommand
(
hidden:
!
verboseHelp
),
new
DevicesCommand
(),
...
...
packages/flutter_tools/lib/src/android/android_studio.dart
View file @
48915069
...
...
@@ -128,7 +128,9 @@ class AndroidStudio implements Comparable<AndroidStudio> {
.
listSync
()
.
where
((
FileSystemEntity
e
)
=>
e
is
Directory
);
for
(
Directory
directory
in
directories
)
{
if
(
directory
.
basename
==
'Android Studio.app'
)
{
final
String
name
=
directory
.
basename
;
// An exact match, or something like 'Android Studio 3.0 Preview.app'.
if
(
name
.
startsWith
(
'Android Studio'
)
&&
name
.
endsWith
(
'.app'
))
{
candidatePaths
.
add
(
directory
);
}
else
if
(!
directory
.
path
.
endsWith
(
'.app'
))
{
_checkForStudio
(
directory
.
path
);
...
...
packages/flutter_tools/lib/src/commands/analyze.dart
View file @
48915069
...
...
@@ -23,7 +23,7 @@ class AnalyzeCommand extends FlutterCommand {
argParser
.
addOption
(
'dart-sdk'
,
valueHelp:
'path-to-sdk'
,
help:
'The path to the Dart SDK.'
,
hide:
!
verboseHelp
);
// Hidden option to enable a benchmarking mode.
argParser
.
addFlag
(
'benchmark'
,
negatable:
false
,
hide:
!
verboseHelp
,
help:
'Also output the analysis time'
);
argParser
.
addFlag
(
'benchmark'
,
negatable:
false
,
hide:
!
verboseHelp
,
help:
'Also output the analysis time
.
'
);
usesPubOption
();
...
...
packages/flutter_tools/lib/src/commands/config.dart
View file @
48915069
...
...
@@ -3,23 +3,27 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:convert'
;
import
'../android/android_studio.dart'
;
import
'../globals.dart'
;
import
'../runner/flutter_command.dart'
;
import
'../usage.dart'
;
class
ConfigCommand
extends
FlutterCommand
{
ConfigCommand
()
{
ConfigCommand
(
{
bool
verboseHelp:
false
}
)
{
argParser
.
addFlag
(
'analytics'
,
negatable:
true
,
help:
'Enable or disable reporting anonymously tool usage statistics and crash reports.'
);
argParser
.
addFlag
(
'clear-ios-signing-cert'
,
argParser
.
addFlag
(
'clear-ios-signing-cert'
,
negatable:
false
,
help:
'Clear the saved development certificate choice used to sign apps for iOS device deployment'
);
help:
'Clear the saved development certificate choice used to sign apps for iOS device deployment.'
);
argParser
.
addOption
(
'gradle-dir'
,
help:
'The gradle install directory.'
);
argParser
.
addOption
(
'android-studio-dir'
,
help:
'The Android Studio install directory.'
);
argParser
.
addFlag
(
'machine'
,
negatable:
false
,
hide:
!
verboseHelp
,
help:
'Pring config values as json.'
);
}
@override
...
...
@@ -53,6 +57,9 @@ class ConfigCommand extends FlutterCommand {
@override
Future
<
Null
>
runCommand
()
async
{
if
(
argResults
[
'machine'
])
return
handleMachine
();
if
(
argResults
.
wasParsed
(
'analytics'
))
{
final
bool
value
=
argResults
[
'analytics'
];
flutterUsage
.
enabled
=
value
;
...
...
@@ -72,6 +79,21 @@ class ConfigCommand extends FlutterCommand {
printStatus
(
usage
);
}
Future
<
Null
>
handleMachine
()
async
{
// Get all the current values.
final
Map
<
String
,
dynamic
>
results
=
<
String
,
dynamic
>{};
for
(
String
key
in
config
.
keys
)
{
results
[
key
]
=
config
.
getValue
(
key
);
}
// Ensure we send any calculated ones, if overrides don't exist.
if
(
results
[
'android-studio-dir'
]
==
null
&&
androidStudio
!=
null
)
{
results
[
'android-studio-dir'
]
=
androidStudio
.
directory
;
}
printStatus
(
JSON
.
encode
(
results
));
}
void
_updateConfig
(
String
keyName
,
String
keyValue
)
{
if
(
keyValue
.
isEmpty
)
{
config
.
removeValue
(
keyName
);
...
...
packages/flutter_tools/test/config_test.dart
View file @
48915069
...
...
@@ -2,17 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:convert'
;
import
'package:flutter_tools/src/android/android_studio.dart'
;
import
'package:flutter_tools/src/base/config.dart'
;
import
'package:flutter_tools/src/base/context.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/commands/config.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:test/test.dart'
;
import
'src/context.dart'
;
void
main
(
)
{
Config
config
;
MockAndroidStudio
mockAndroidStudio
;
setUp
(()
{
final
Directory
tempDiretory
=
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_test'
);
final
File
file
=
fs
.
file
(
fs
.
path
.
join
(
tempDiretory
.
path
,
'.settings'
));
final
Directory
tempDire
c
tory
=
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_test'
);
final
File
file
=
fs
.
file
(
fs
.
path
.
join
(
tempDire
c
tory
.
path
,
'.settings'
));
config
=
new
Config
(
file
);
mockAndroidStudio
=
new
MockAndroidStudio
();
});
group
(
'config'
,
()
{
...
...
@@ -32,5 +43,24 @@ void main() {
expect
(
config
.
getValue
(
'foo'
),
null
);
expect
(
config
.
keys
,
isNot
(
contains
(
'foo'
)));
});
testUsingContext
(
'machine flag'
,
()
async
{
final
BufferLogger
logger
=
context
[
Logger
];
final
ConfigCommand
command
=
new
ConfigCommand
();
await
command
.
handleMachine
();
expect
(
logger
.
statusText
,
isNotEmpty
);
final
dynamic
json
=
JSON
.
decode
(
logger
.
statusText
);
expect
(
json
,
isMap
);
expect
(
json
.
containsKey
(
'android-studio-dir'
),
true
);
expect
(
json
[
'android-studio-dir'
],
isNotNull
);
},
overrides:
<
Type
,
Generator
>{
AndroidStudio:
()
=>
mockAndroidStudio
,
});
});
}
class
MockAndroidStudio
extends
Mock
implements
AndroidStudio
,
Comparable
<
AndroidStudio
>
{
@override
String
get
directory
=>
'path/to/android/stdio'
;
}
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