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
52d0434b
Commit
52d0434b
authored
May 10, 2016
by
Devon Carew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create a flutter setup command (#3837)
parent
067715e3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
183 additions
and
6 deletions
+183
-6
executable.dart
packages/flutter_tools/lib/executable.dart
+2
-0
setup.dart
packages/flutter_tools/lib/src/commands/setup.dart
+159
-0
doctor.dart
packages/flutter_tools/lib/src/doctor.dart
+22
-6
No files found.
packages/flutter_tools/lib/executable.dart
View file @
52d0434b
...
@@ -23,6 +23,7 @@ import 'src/commands/drive.dart';
...
@@ -23,6 +23,7 @@ import 'src/commands/drive.dart';
import
'src/commands/install.dart'
;
import
'src/commands/install.dart'
;
import
'src/commands/listen.dart'
;
import
'src/commands/listen.dart'
;
import
'src/commands/logs.dart'
;
import
'src/commands/logs.dart'
;
import
'src/commands/setup.dart'
;
import
'src/commands/precache.dart'
;
import
'src/commands/precache.dart'
;
import
'src/commands/refresh.dart'
;
import
'src/commands/refresh.dart'
;
import
'src/commands/run.dart'
;
import
'src/commands/run.dart'
;
...
@@ -70,6 +71,7 @@ Future<Null> main(List<String> args) async {
...
@@ -70,6 +71,7 @@ Future<Null> main(List<String> args) async {
..
addCommand
(
new
RunCommand
())
..
addCommand
(
new
RunCommand
())
..
addCommand
(
new
RunMojoCommand
(
hidden:
!
verboseHelp
))
..
addCommand
(
new
RunMojoCommand
(
hidden:
!
verboseHelp
))
..
addCommand
(
new
ScreenshotCommand
())
..
addCommand
(
new
ScreenshotCommand
())
..
addCommand
(
new
SetupCommand
(
hidden:
!
verboseHelp
))
..
addCommand
(
new
SkiaCommand
())
..
addCommand
(
new
SkiaCommand
())
..
addCommand
(
new
StopCommand
())
..
addCommand
(
new
StopCommand
())
..
addCommand
(
new
TestCommand
())
..
addCommand
(
new
TestCommand
())
...
...
packages/flutter_tools/lib/src/commands/setup.dart
0 → 100644
View file @
52d0434b
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:io'
;
import
'package:path/path.dart'
as
path
;
import
'../base/os.dart'
;
import
'../base/process.dart'
;
import
'../doctor.dart'
;
import
'../artifacts.dart'
;
import
'../globals.dart'
;
import
'../runner/flutter_command.dart'
;
/// This setup command will install dependencies necessary for Flutter development.
///
/// This is a hidden command, and is currently designed to work in a custom kiosk
/// environment, but may be generalized in the future.
class
SetupCommand
extends
FlutterCommand
{
SetupCommand
({
this
.
hidden
:
false
});
@override
final
String
name
=
'setup'
;
@override
final
String
description
=
'Setup a machine to support Flutter development.'
;
@override
final
bool
hidden
;
@override
bool
get
requiresProjectRoot
=>
false
;
@override
Future
<
int
>
runInProject
()
async
{
printStatus
(
'Running Flutter setup...'
);
// setup brew on mac
if
(
os
.
isMacOS
)
{
printStatus
(
'
\n
Checking brew:'
);
if
(
os
.
which
(
'brew'
)
==
null
)
{
printError
(
'homebrew is not installed; please install at http://brew.sh/.'
);
}
else
{
printStatus
(
'brew is installed.'
);
await
runCommandAndStreamOutput
(<
String
>[
'brew'
,
'install'
,
'ideviceinstaller'
]);
await
runCommandAndStreamOutput
(<
String
>[
'brew'
,
'install'
,
'ios-deploy'
]);
}
}
// setup atom
printStatus
(
'
\n
Checking Atom:'
);
String
apmPath
=
os
.
which
(
'apm'
)?.
path
;
if
(
apmPath
==
null
&&
FileSystemEntity
.
isFileSync
(
'/usr/local/bin/apm'
))
apmPath
=
'/usr/local/bin/apm'
;
if
(
apmPath
==
null
&&
FileSystemEntity
.
isFileSync
(
'/usr/bin/apm'
))
apmPath
=
'/usr/bin/apm'
;
if
(
apmPath
==
null
)
{
final
String
expectedLocation
=
'/Applications/Atom.app/Contents/Resources/app/apm/bin/apm'
;
if
(
FileSystemEntity
.
isFileSync
(
expectedLocation
))
apmPath
=
expectedLocation
;
}
if
(
apmPath
==
null
)
{
printError
(
'Unable to locate the Atom installation.'
);
}
else
{
printStatus
(
'apm command available at
$apmPath
'
);
AtomValidator
atomValidator
=
new
AtomValidator
();
if
(!
atomValidator
.
hasPackage
(
'dartlang'
))
await
runCommandAndStreamOutput
(<
String
>[
apmPath
,
'install'
,
'dartlang'
]);
else
printStatus
(
'dartlang plugin installed'
);
if
(!
atomValidator
.
hasPackage
(
'flutter'
))
await
runCommandAndStreamOutput
(<
String
>[
apmPath
,
'install'
,
'flutter'
]);
else
printStatus
(
'flutter plugin installed'
);
// Set up the ~/.atom/config.cson file - make sure the path the the
// flutter and dart sdks are correct.
_updateAtomConfigFile
();
}
// run doctor
printStatus
(
'
\n
Flutter doctor:'
);
bool
goodInstall
=
doctor
.
diagnose
();
// Validate that flutter is available on the path.
if
(
os
.
which
(
'flutter'
)
==
null
)
{
printError
(
'
\n
The flutter command is not available on the path.
\n
'
'Please set up your PATH environment variable to point to the flutter/bin directory.'
);
}
else
{
printStatus
(
'
\n
The flutter command is available on the path.'
);
}
if
(
goodInstall
)
printStatus
(
'
\n
Flutter setup complete!'
);
return
goodInstall
?
0
:
1
;
}
// Quick-and-dirty manipulation of the cson file.
void
_updateAtomConfigFile
()
{
// flutter:
// flutterRoot: "..."
// dartlang:
// sdkLocation: "..."
String
flutterRoot
=
path
.
normalize
(
path
.
absolute
(
ArtifactStore
.
flutterRoot
));
String
sdkLocation
=
path
.
join
(
flutterRoot
,
'bin/cache/dart-sdk'
);
File
file
=
AtomValidator
.
getConfigFile
();
if
(
file
.
existsSync
())
{
String
cson
=
file
.
readAsStringSync
();
cson
=
cson
.
trimRight
()
+
'
\n
'
;
List
<
String
>
lines
=
cson
.
split
(
'
\n
'
).
map
((
String
line
)
=>
line
.
trim
()).
toList
();
if
(!
lines
.
contains
(
'flutter:'
))
{
cson
+=
'''
flutter:
flutterRoot: "
$flutterRoot
"
'''
;
}
if
(!
lines
.
contains
(
'dartlang:'
))
{
cson
+=
'''
dartlang:
sdkLocation: "
$sdkLocation
"
'''
;
}
if
(
cson
.
trim
()
!=
file
.
readAsStringSync
().
trim
())
{
printStatus
(
'Updating
${file.path}
'
);
file
.
writeAsStringSync
(
cson
);
}
}
else
{
// Create a new config file.
printStatus
(
'Creating
${file.path}
'
);
String
cson
=
'''
"*":
flutter:
flutterRoot: "
$flutterRoot
"
dartlang:
sdkLocation: "
$sdkLocation
"
'''
;
file
.
writeAsStringSync
(
cson
);
}
}
}
packages/flutter_tools/lib/src/doctor.dart
View file @
52d0434b
...
@@ -37,7 +37,7 @@ class Doctor {
...
@@ -37,7 +37,7 @@ class Doctor {
if
(
_iosWorkflow
.
appliesToHostPlatform
)
if
(
_iosWorkflow
.
appliesToHostPlatform
)
_validators
.
add
(
_iosWorkflow
);
_validators
.
add
(
_iosWorkflow
);
_validators
.
add
(
new
_
AtomValidator
());
_validators
.
add
(
new
AtomValidator
());
}
}
static
void
initGlobal
()
{
static
void
initGlobal
()
{
...
@@ -94,8 +94,9 @@ class Doctor {
...
@@ -94,8 +94,9 @@ class Doctor {
}
}
/// Print verbose information about the state of installed tooling.
/// Print verbose information about the state of installed tooling.
void
diagnose
()
{
bool
diagnose
()
{
bool
firstLine
=
true
;
bool
firstLine
=
true
;
bool
doctorResult
=
true
;
for
(
DoctorValidator
validator
in
_validators
)
{
for
(
DoctorValidator
validator
in
_validators
)
{
if
(!
firstLine
)
if
(!
firstLine
)
...
@@ -104,6 +105,9 @@ class Doctor {
...
@@ -104,6 +105,9 @@ class Doctor {
ValidationResult
result
=
validator
.
validate
();
ValidationResult
result
=
validator
.
validate
();
if
(
result
.
type
==
ValidationType
.
missing
)
doctorResult
=
false
;
if
(
result
.
statusInfo
!=
null
)
if
(
result
.
statusInfo
!=
null
)
printStatus
(
'
${result.leadingBox}
${validator.title}
(
${result.statusInfo}
)'
);
printStatus
(
'
${result.leadingBox}
${validator.title}
(
${result.statusInfo}
)'
);
else
else
...
@@ -119,6 +123,8 @@ class Doctor {
...
@@ -119,6 +123,8 @@ class Doctor {
}
}
}
}
}
}
return
doctorResult
;
}
}
bool
get
canListAnything
=>
workflows
.
any
((
Workflow
workflow
)
=>
workflow
.
canListDevices
);
bool
get
canListAnything
=>
workflows
.
any
((
Workflow
workflow
)
=>
workflow
.
canListDevices
);
...
@@ -214,8 +220,13 @@ class _FlutterValidator extends DoctorValidator {
...
@@ -214,8 +220,13 @@ class _FlutterValidator extends DoctorValidator {
}
}
}
}
class
_AtomValidator
extends
DoctorValidator
{
class
AtomValidator
extends
DoctorValidator
{
_AtomValidator
()
:
super
(
'Atom - a lightweight development environment for Flutter'
);
AtomValidator
()
:
super
(
'Atom - a lightweight development environment for Flutter'
);
static
File
getConfigFile
()
{
// ~/.atom/config.cson
return
new
File
(
path
.
join
(
_getAtomHomePath
(),
'config.cson'
));
}
static
String
_getAtomHomePath
()
{
static
String
_getAtomHomePath
()
{
final
Map
<
String
,
String
>
env
=
Platform
.
environment
;
final
Map
<
String
,
String
>
env
=
Platform
.
environment
;
...
@@ -241,8 +252,7 @@ class _AtomValidator extends DoctorValidator {
...
@@ -241,8 +252,7 @@ class _AtomValidator extends DoctorValidator {
installCount
++;
installCount
++;
}
}
String
flutterPluginPath
=
path
.
join
(
_getAtomHomePath
(),
'packages'
,
'flutter'
);
if
(!
hasPackage
(
'flutter'
))
{
if
(!
FileSystemEntity
.
isDirectorySync
(
flutterPluginPath
))
{
messages
.
add
(
new
ValidationMessage
.
error
(
messages
.
add
(
new
ValidationMessage
.
error
(
'Flutter plugin not installed; this adds Flutter specific functionality to Atom.
\n
'
'Flutter plugin not installed; this adds Flutter specific functionality to Atom.
\n
'
'Install the
\'
flutter
\'
plugin in Atom or run
\'
apm install flutter
\'
.'
'Install the
\'
flutter
\'
plugin in Atom or run
\'
apm install flutter
\'
.'
...
@@ -251,6 +261,7 @@ class _AtomValidator extends DoctorValidator {
...
@@ -251,6 +261,7 @@ class _AtomValidator extends DoctorValidator {
installCount
++;
installCount
++;
try
{
try
{
String
flutterPluginPath
=
path
.
join
(
_getAtomHomePath
(),
'packages'
,
'flutter'
);
File
packageFile
=
new
File
(
path
.
join
(
flutterPluginPath
,
'package.json'
));
File
packageFile
=
new
File
(
path
.
join
(
flutterPluginPath
,
'package.json'
));
dynamic
packageInfo
=
JSON
.
decode
(
packageFile
.
readAsStringSync
());
dynamic
packageInfo
=
JSON
.
decode
(
packageFile
.
readAsStringSync
());
String
version
=
packageInfo
[
'version'
];
String
version
=
packageInfo
[
'version'
];
...
@@ -267,4 +278,9 @@ class _AtomValidator extends DoctorValidator {
...
@@ -267,4 +278,9 @@ class _AtomValidator extends DoctorValidator {
messages
messages
);
);
}
}
bool
hasPackage
(
String
packageName
)
{
String
packagePath
=
path
.
join
(
_getAtomHomePath
(),
'packages'
,
packageName
);
return
FileSystemEntity
.
isDirectorySync
(
packagePath
);
}
}
}
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