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
410d9921
Unverified
Commit
410d9921
authored
Jan 06, 2022
by
Jenn Magder
Committed by
GitHub
Jan 06, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate emulators, packages, upgrade, and downgrade to null safety (#95712)
parent
18c59cdb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
106 deletions
+112
-106
downgrade.dart
packages/flutter_tools/lib/src/commands/downgrade.dart
+39
-36
emulators.dart
packages/flutter_tools/lib/src/commands/emulators.dart
+21
-18
packages.dart
packages/flutter_tools/lib/src/commands/packages.dart
+22
-22
upgrade.dart
packages/flutter_tools/lib/src/commands/upgrade.dart
+28
-28
pub.dart
packages/flutter_tools/lib/src/dart/pub.dart
+2
-2
No files found.
packages/flutter_tools/lib/src/commands/downgrade.dart
View file @
410d9921
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:process/process.dart'
;
import
'package:process/process.dart'
;
import
'../base/common.dart'
;
import
'../base/common.dart'
;
...
@@ -31,13 +29,13 @@ import '../version.dart';
...
@@ -31,13 +29,13 @@ import '../version.dart';
class
DowngradeCommand
extends
FlutterCommand
{
class
DowngradeCommand
extends
FlutterCommand
{
DowngradeCommand
({
DowngradeCommand
({
bool
verboseHelp
=
false
,
bool
verboseHelp
=
false
,
PersistentToolState
persistentToolState
,
PersistentToolState
?
persistentToolState
,
Logger
logger
,
Logger
?
logger
,
ProcessManager
processManager
,
ProcessManager
?
processManager
,
FlutterVersion
flutterVersion
,
FlutterVersion
?
flutterVersion
,
Terminal
terminal
,
Terminal
?
terminal
,
Stdio
stdio
,
Stdio
?
stdio
,
FileSystem
fileSystem
,
FileSystem
?
fileSystem
,
})
:
_terminal
=
terminal
,
})
:
_terminal
=
terminal
,
_flutterVersion
=
flutterVersion
,
_flutterVersion
=
flutterVersion
,
_persistentToolState
=
persistentToolState
,
_persistentToolState
=
persistentToolState
,
...
@@ -61,14 +59,14 @@ class DowngradeCommand extends FlutterCommand {
...
@@ -61,14 +59,14 @@ class DowngradeCommand extends FlutterCommand {
);
);
}
}
Terminal
_terminal
;
Terminal
?
_terminal
;
FlutterVersion
_flutterVersion
;
FlutterVersion
?
_flutterVersion
;
PersistentToolState
_persistentToolState
;
PersistentToolState
?
_persistentToolState
;
ProcessUtils
_processUtils
;
ProcessUtils
?
_processUtils
;
ProcessManager
_processManager
;
ProcessManager
?
_processManager
;
Logger
_logger
;
Logger
?
_logger
;
Stdio
_stdio
;
Stdio
?
_stdio
;
FileSystem
_fileSystem
;
FileSystem
?
_fileSystem
;
@override
@override
String
get
description
=>
'Downgrade Flutter to the last active version for the current channel.'
;
String
get
description
=>
'Downgrade Flutter to the last active version for the current channel.'
;
...
@@ -89,25 +87,26 @@ class DowngradeCommand extends FlutterCommand {
...
@@ -89,25 +87,26 @@ class DowngradeCommand extends FlutterCommand {
_flutterVersion
??=
globals
.
flutterVersion
;
_flutterVersion
??=
globals
.
flutterVersion
;
_persistentToolState
??=
globals
.
persistentToolState
;
_persistentToolState
??=
globals
.
persistentToolState
;
_processManager
??=
globals
.
processManager
;
_processManager
??=
globals
.
processManager
;
_processUtils
??=
ProcessUtils
(
processManager:
_processManager
,
logger:
_logger
);
_processUtils
??=
ProcessUtils
(
processManager:
_processManager
!,
logger:
_logger
!
);
_stdio
??=
globals
.
stdio
;
_stdio
??=
globals
.
stdio
;
_fileSystem
??=
globals
.
fs
;
_fileSystem
??=
globals
.
fs
;
String
workingDirectory
=
Cache
.
flutterRoot
;
String
workingDirectory
=
Cache
.
flutterRoot
!
;
if
(
argResults
.
wasParsed
(
'working-directory'
))
{
if
(
argResults
!
.
wasParsed
(
'working-directory'
))
{
workingDirectory
=
stringArg
(
'working-directory'
);
workingDirectory
=
stringArg
(
'working-directory'
)
!
;
_flutterVersion
=
FlutterVersion
(
workingDirectory:
workingDirectory
);
_flutterVersion
=
FlutterVersion
(
workingDirectory:
workingDirectory
);
}
}
final
String
currentChannel
=
_flutterVersion
.
channel
;
final
String
currentChannel
=
_flutterVersion
!
.
channel
;
final
Channel
channel
=
getChannelForName
(
currentChannel
);
final
Channel
?
channel
=
getChannelForName
(
currentChannel
);
if
(
channel
==
null
)
{
if
(
channel
==
null
)
{
throwToolExit
(
throwToolExit
(
'Flutter is not currently on a known channel. Use "flutter channel <name>" '
'Flutter is not currently on a known channel. Use "flutter channel <name>" '
'to switch to an official channel.'
,
'to switch to an official channel.'
,
);
);
}
}
final
String
lastFlutterVersion
=
_persistentToolState
.
lastActiveVersion
(
channel
);
final
PersistentToolState
persistentToolState
=
_persistentToolState
!;
final
String
currentFlutterVersion
=
_flutterVersion
.
frameworkRevision
;
final
String
?
lastFlutterVersion
=
persistentToolState
.
lastActiveVersion
(
channel
);
final
String
?
currentFlutterVersion
=
_flutterVersion
?.
frameworkRevision
;
if
(
lastFlutterVersion
==
null
||
currentFlutterVersion
==
lastFlutterVersion
)
{
if
(
lastFlutterVersion
==
null
||
currentFlutterVersion
==
lastFlutterVersion
)
{
final
String
trailing
=
await
_createErrorMessage
(
workingDirectory
,
channel
);
final
String
trailing
=
await
_createErrorMessage
(
workingDirectory
,
channel
);
throwToolExit
(
throwToolExit
(
...
@@ -117,7 +116,8 @@ class DowngradeCommand extends FlutterCommand {
...
@@ -117,7 +116,8 @@ class DowngradeCommand extends FlutterCommand {
}
}
// Detect unknown versions.
// Detect unknown versions.
final
RunResult
parseResult
=
await
_processUtils
.
run
(<
String
>[
final
ProcessUtils
processUtils
=
_processUtils
!;
final
RunResult
parseResult
=
await
processUtils
.
run
(<
String
>[
'git'
,
'describe'
,
'--tags'
,
lastFlutterVersion
,
'git'
,
'describe'
,
'--tags'
,
lastFlutterVersion
,
],
workingDirectory:
workingDirectory
);
],
workingDirectory:
workingDirectory
);
if
(
parseResult
.
exitCode
!=
0
)
{
if
(
parseResult
.
exitCode
!=
0
)
{
...
@@ -126,25 +126,28 @@ class DowngradeCommand extends FlutterCommand {
...
@@ -126,25 +126,28 @@ class DowngradeCommand extends FlutterCommand {
final
String
humanReadableVersion
=
parseResult
.
stdout
;
final
String
humanReadableVersion
=
parseResult
.
stdout
;
// If there is a terminal attached, prompt the user to confirm the downgrade.
// If there is a terminal attached, prompt the user to confirm the downgrade.
if
(
_stdio
.
hasTerminal
&&
boolArg
(
'prompt'
))
{
final
Stdio
stdio
=
_stdio
!;
_terminal
.
usesTerminalUi
=
true
;
final
Terminal
terminal
=
_terminal
!;
final
String
result
=
await
_terminal
.
promptForCharInput
(
final
Logger
logger
=
_logger
!;
if
(
stdio
.
hasTerminal
&&
boolArg
(
'prompt'
))
{
terminal
.
usesTerminalUi
=
true
;
final
String
result
=
await
terminal
.
promptForCharInput
(
const
<
String
>[
'y'
,
'n'
],
const
<
String
>[
'y'
,
'n'
],
prompt:
'Downgrade flutter to version
$humanReadableVersion
?'
,
prompt:
'Downgrade flutter to version
$humanReadableVersion
?'
,
logger:
_
logger
,
logger:
logger
,
);
);
if
(
result
==
'n'
)
{
if
(
result
==
'n'
)
{
return
FlutterCommandResult
.
success
();
return
FlutterCommandResult
.
success
();
}
}
}
else
{
}
else
{
_
logger
.
printStatus
(
'Downgrading Flutter to version
$humanReadableVersion
'
);
logger
.
printStatus
(
'Downgrading Flutter to version
$humanReadableVersion
'
);
}
}
// To downgrade the tool, we perform a git checkout --hard, and then
// To downgrade the tool, we perform a git checkout --hard, and then
// switch channels. The version recorded must have existed on that branch
// switch channels. The version recorded must have existed on that branch
// so this operation is safe.
// so this operation is safe.
try
{
try
{
await
_
processUtils
.
run
(
await
processUtils
.
run
(
<
String
>[
'git'
,
'reset'
,
'--hard'
,
lastFlutterVersion
],
<
String
>[
'git'
,
'reset'
,
'--hard'
,
lastFlutterVersion
],
throwOnError:
true
,
throwOnError:
true
,
workingDirectory:
workingDirectory
,
workingDirectory:
workingDirectory
,
...
@@ -158,7 +161,7 @@ class DowngradeCommand extends FlutterCommand {
...
@@ -158,7 +161,7 @@ class DowngradeCommand extends FlutterCommand {
);
);
}
}
try
{
try
{
await
_
processUtils
.
run
(
await
processUtils
.
run
(
<
String
>[
'git'
,
'checkout'
,
currentChannel
,
'--'
],
<
String
>[
'git'
,
'checkout'
,
currentChannel
,
'--'
],
throwOnError:
true
,
throwOnError:
true
,
workingDirectory:
workingDirectory
,
workingDirectory:
workingDirectory
,
...
@@ -172,7 +175,7 @@ class DowngradeCommand extends FlutterCommand {
...
@@ -172,7 +175,7 @@ class DowngradeCommand extends FlutterCommand {
);
);
}
}
await
FlutterVersion
.
resetFlutterVersionFreshnessCheck
();
await
FlutterVersion
.
resetFlutterVersionFreshnessCheck
();
_
logger
.
printStatus
(
'Success'
);
logger
.
printStatus
(
'Success'
);
return
FlutterCommandResult
.
success
();
return
FlutterCommandResult
.
success
();
}
}
...
@@ -183,11 +186,11 @@ class DowngradeCommand extends FlutterCommand {
...
@@ -183,11 +186,11 @@ class DowngradeCommand extends FlutterCommand {
if
(
channel
==
currentChannel
)
{
if
(
channel
==
currentChannel
)
{
continue
;
continue
;
}
}
final
String
sha
=
_persistentToolState
.
lastActiveVersion
(
channel
);
final
String
?
sha
=
_persistentToolState
?
.
lastActiveVersion
(
channel
);
if
(
sha
==
null
)
{
if
(
sha
==
null
)
{
continue
;
continue
;
}
}
final
RunResult
parseResult
=
await
_processUtils
.
run
(<
String
>[
final
RunResult
parseResult
=
await
_processUtils
!
.
run
(<
String
>[
'git'
,
'describe'
,
'--tags'
,
sha
,
'git'
,
'describe'
,
'--tags'
,
sha
,
],
workingDirectory:
workingDirectory
);
],
workingDirectory:
workingDirectory
);
if
(
parseResult
.
exitCode
==
0
)
{
if
(
parseResult
.
exitCode
==
0
)
{
...
...
packages/flutter_tools/lib/src/commands/emulators.dart
View file @
410d9921
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:args/args.dart'
;
import
'../base/common.dart'
;
import
'../base/common.dart'
;
import
'../base/utils.dart'
;
import
'../base/utils.dart'
;
...
@@ -39,22 +39,22 @@ class EmulatorsCommand extends FlutterCommand {
...
@@ -39,22 +39,22 @@ class EmulatorsCommand extends FlutterCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
if
(
globals
.
doctor
.
workflows
.
every
((
Workflow
w
)
=>
!
w
.
canListEmulators
))
{
if
(
globals
.
doctor
!
.
workflows
.
every
((
Workflow
w
)
=>
!
w
.
canListEmulators
))
{
throwToolExit
(
throwToolExit
(
'Unable to find any emulator sources. Please ensure you have some
\n
'
'Unable to find any emulator sources. Please ensure you have some
\n
'
'Android AVD images
${globals.platform.isMacOS ? 'or an iOS Simulator ' : ''}
available.'
,
'Android AVD images
${globals.platform.isMacOS ? 'or an iOS Simulator ' : ''}
available.'
,
exitCode:
1
);
exitCode:
1
);
}
}
final
ArgResults
argumentResults
=
argResults
!;
if
(
argResults
.
wasParsed
(
'launch'
))
{
if
(
arg
ument
Results
.
wasParsed
(
'launch'
))
{
final
bool
coldBoot
=
argResults
.
wasParsed
(
'cold'
);
final
bool
coldBoot
=
arg
ument
Results
.
wasParsed
(
'cold'
);
await
_launchEmulator
(
stringArg
(
'launch'
),
coldBoot:
coldBoot
);
await
_launchEmulator
(
stringArg
(
'launch'
)
!
,
coldBoot:
coldBoot
);
}
else
if
(
argResults
.
wasParsed
(
'create'
))
{
}
else
if
(
arg
ument
Results
.
wasParsed
(
'create'
))
{
await
_createEmulator
(
name:
stringArg
(
'name'
));
await
_createEmulator
(
name:
stringArg
(
'name'
));
}
else
{
}
else
{
final
String
searchText
=
final
String
?
searchText
=
arg
Results
.
rest
!=
null
&&
arg
Results
.
rest
.
isNotEmpty
arg
umentResults
.
rest
!=
null
&&
argument
Results
.
rest
.
isNotEmpty
?
argResults
.
rest
.
first
?
arg
ument
Results
.
rest
.
first
:
null
;
:
null
;
await
_listEmulators
(
searchText
);
await
_listEmulators
(
searchText
);
}
}
...
@@ -62,9 +62,9 @@ class EmulatorsCommand extends FlutterCommand {
...
@@ -62,9 +62,9 @@ class EmulatorsCommand extends FlutterCommand {
return
FlutterCommandResult
.
success
();
return
FlutterCommandResult
.
success
();
}
}
Future
<
void
>
_launchEmulator
(
String
id
,
{
bool
coldBoot
})
async
{
Future
<
void
>
_launchEmulator
(
String
id
,
{
required
bool
coldBoot
})
async
{
final
List
<
Emulator
>
emulators
=
final
List
<
Emulator
>
emulators
=
await
emulatorManager
.
getEmulatorsMatching
(
id
);
await
emulatorManager
!
.
getEmulatorsMatching
(
id
);
if
(
emulators
.
isEmpty
)
{
if
(
emulators
.
isEmpty
)
{
globals
.
printStatus
(
"No emulator found that matches '
$id
'."
);
globals
.
printStatus
(
"No emulator found that matches '
$id
'."
);
...
@@ -78,23 +78,26 @@ class EmulatorsCommand extends FlutterCommand {
...
@@ -78,23 +78,26 @@ class EmulatorsCommand extends FlutterCommand {
}
}
}
}
Future
<
void
>
_createEmulator
({
String
name
})
async
{
Future
<
void
>
_createEmulator
({
String
?
name
})
async
{
final
CreateEmulatorResult
createResult
=
final
CreateEmulatorResult
createResult
=
await
emulatorManager
.
createEmulator
(
name:
name
);
await
emulatorManager
!
.
createEmulator
(
name:
name
);
if
(
createResult
.
success
)
{
if
(
createResult
.
success
)
{
globals
.
printStatus
(
"Emulator '
${createResult.emulatorName}
' created successfully."
);
globals
.
printStatus
(
"Emulator '
${createResult.emulatorName}
' created successfully."
);
}
else
{
}
else
{
globals
.
printStatus
(
"Failed to create emulator '
${createResult.emulatorName}
'.
\n
"
);
globals
.
printStatus
(
"Failed to create emulator '
${createResult.emulatorName}
'.
\n
"
);
globals
.
printStatus
(
createResult
.
error
.
trim
());
final
String
?
error
=
createResult
.
error
;
if
(
error
!=
null
)
{
globals
.
printStatus
(
error
.
trim
());
}
_printAdditionalInfo
();
_printAdditionalInfo
();
}
}
}
}
Future
<
void
>
_listEmulators
(
String
searchText
)
async
{
Future
<
void
>
_listEmulators
(
String
?
searchText
)
async
{
final
List
<
Emulator
>
emulators
=
searchText
==
null
final
List
<
Emulator
>
emulators
=
searchText
==
null
?
await
emulatorManager
.
getAllAvailableEmulators
()
?
await
emulatorManager
!
.
getAllAvailableEmulators
()
:
await
emulatorManager
.
getEmulatorsMatching
(
searchText
);
:
await
emulatorManager
!
.
getEmulatorsMatching
(
searchText
);
if
(
emulators
.
isEmpty
)
{
if
(
emulators
.
isEmpty
)
{
globals
.
printStatus
(
'No emulators available.'
);
globals
.
printStatus
(
'No emulators available.'
);
...
...
packages/flutter_tools/lib/src/commands/packages.dart
View file @
410d9921
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:args/args.dart'
;
import
'package:args/args.dart'
;
import
'../base/common.dart'
;
import
'../base/common.dart'
;
...
@@ -55,7 +53,7 @@ class PackagesCommand extends FlutterCommand {
...
@@ -55,7 +53,7 @@ class PackagesCommand extends FlutterCommand {
String
get
category
=>
FlutterCommandCategory
.
project
;
String
get
category
=>
FlutterCommandCategory
.
project
;
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
=>
null
;
Future
<
FlutterCommandResult
>
runCommand
()
async
=>
FlutterCommandResult
.
fail
()
;
}
}
class
PackagesGetCommand
extends
FlutterCommand
{
class
PackagesGetCommand
extends
FlutterCommand
{
...
@@ -79,15 +77,16 @@ class PackagesGetCommand extends FlutterCommand {
...
@@ -79,15 +77,16 @@ class PackagesGetCommand extends FlutterCommand {
@override
@override
String
get
invocation
{
String
get
invocation
{
return
'
${runner.executableName}
pub
$name
[<target directory>]'
;
return
'
${runner
!
.executableName}
pub
$name
[<target directory>]'
;
}
}
/// The pub packages usage values are incorrect since these are calculated/sent
/// The pub packages usage values are incorrect since these are calculated/sent
/// before pub get completes. This needs to be performed after dependency resolution.
/// before pub get completes. This needs to be performed after dependency resolution.
@override
@override
Future
<
CustomDimensions
>
get
usageValues
async
{
Future
<
CustomDimensions
>
get
usageValues
async
{
final
String
workingDirectory
=
argResults
.
rest
.
length
==
1
?
argResults
.
rest
[
0
]
:
null
;
final
ArgResults
argumentResults
=
argResults
!;
final
String
target
=
findProjectRoot
(
globals
.
fs
,
workingDirectory
);
final
String
?
workingDirectory
=
argumentResults
.
rest
.
length
==
1
?
argumentResults
.
rest
[
0
]
:
null
;
final
String
?
target
=
findProjectRoot
(
globals
.
fs
,
workingDirectory
);
if
(
target
==
null
)
{
if
(
target
==
null
)
{
return
const
CustomDimensions
();
return
const
CustomDimensions
();
}
}
...
@@ -118,7 +117,7 @@ class PackagesGetCommand extends FlutterCommand {
...
@@ -118,7 +117,7 @@ class PackagesGetCommand extends FlutterCommand {
Future
<
void
>
_runPubGet
(
String
directory
,
FlutterProject
flutterProject
)
async
{
Future
<
void
>
_runPubGet
(
String
directory
,
FlutterProject
flutterProject
)
async
{
if
(
flutterProject
.
manifest
.
generateSyntheticPackage
)
{
if
(
flutterProject
.
manifest
.
generateSyntheticPackage
)
{
final
Environment
environment
=
Environment
(
final
Environment
environment
=
Environment
(
artifacts:
globals
.
artifacts
,
artifacts:
globals
.
artifacts
!
,
logger:
globals
.
logger
,
logger:
globals
.
logger
,
cacheDir:
globals
.
cache
.
getRoot
(),
cacheDir:
globals
.
cache
.
getRoot
(),
engineVersion:
globals
.
flutterVersion
.
engineRevision
,
engineVersion:
globals
.
flutterVersion
.
engineRevision
,
...
@@ -159,12 +158,13 @@ class PackagesGetCommand extends FlutterCommand {
...
@@ -159,12 +158,13 @@ class PackagesGetCommand extends FlutterCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
if
(
argResults
.
rest
.
length
>
1
)
{
final
ArgResults
argumentResults
=
argResults
!;
if
(
argumentResults
.
rest
.
length
>
1
)
{
throwToolExit
(
'Too many arguments.
\n
$usage
'
);
throwToolExit
(
'Too many arguments.
\n
$usage
'
);
}
}
final
String
workingDirectory
=
argResults
.
rest
.
length
==
1
?
arg
Results
.
rest
[
0
]
:
null
;
final
String
?
workingDirectory
=
argumentResults
.
rest
.
length
==
1
?
argument
Results
.
rest
[
0
]
:
null
;
final
String
target
=
findProjectRoot
(
globals
.
fs
,
workingDirectory
);
final
String
?
target
=
findProjectRoot
(
globals
.
fs
,
workingDirectory
);
if
(
target
==
null
)
{
if
(
target
==
null
)
{
throwToolExit
(
throwToolExit
(
'Expected to find project root in '
'Expected to find project root in '
...
@@ -207,12 +207,12 @@ class PackagesTestCommand extends FlutterCommand {
...
@@ -207,12 +207,12 @@ class PackagesTestCommand extends FlutterCommand {
@override
@override
String
get
invocation
{
String
get
invocation
{
return
'
${runner.executableName}
pub test [<tests...>]'
;
return
'
${runner
!
.executableName}
pub test [<tests...>]'
;
}
}
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
await
pub
.
batch
(<
String
>[
'run'
,
'test'
,
...
argResults
.
rest
],
context:
PubContext
.
runTest
,
retry:
false
);
await
pub
.
batch
(<
String
>[
'run'
,
'test'
,
...
argResults
!
.
rest
],
context:
PubContext
.
runTest
,
retry:
false
);
return
FlutterCommandResult
.
success
();
return
FlutterCommandResult
.
success
();
}
}
}
}
...
@@ -241,12 +241,12 @@ class PackagesForwardCommand extends FlutterCommand {
...
@@ -241,12 +241,12 @@ class PackagesForwardCommand extends FlutterCommand {
@override
@override
String
get
invocation
{
String
get
invocation
{
return
'
${runner.executableName}
pub
$_commandName
[<arguments...>]'
;
return
'
${runner
!
.executableName}
pub
$_commandName
[<arguments...>]'
;
}
}
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
final
List
<
String
>
subArgs
=
argResults
.
rest
.
toList
()
final
List
<
String
>
subArgs
=
argResults
!
.
rest
.
toList
()
..
removeWhere
((
String
arg
)
=>
arg
==
'--'
);
..
removeWhere
((
String
arg
)
=>
arg
==
'--'
);
await
pub
.
interactively
(<
String
>[
_commandName
,
...
subArgs
],
stdio:
globals
.
stdio
);
await
pub
.
interactively
(<
String
>[
_commandName
,
...
subArgs
],
stdio:
globals
.
stdio
);
return
FlutterCommandResult
.
success
();
return
FlutterCommandResult
.
success
();
...
@@ -268,12 +268,12 @@ class PackagesPassthroughCommand extends FlutterCommand {
...
@@ -268,12 +268,12 @@ class PackagesPassthroughCommand extends FlutterCommand {
@override
@override
String
get
invocation
{
String
get
invocation
{
return
'
${runner.executableName}
packages pub [<arguments...>]'
;
return
'
${runner
!
.executableName}
packages pub [<arguments...>]'
;
}
}
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
await
pub
.
interactively
(
argResults
.
rest
,
stdio:
globals
.
stdio
);
await
pub
.
interactively
(
argResults
!
.
rest
,
stdio:
globals
.
stdio
);
return
FlutterCommandResult
.
success
();
return
FlutterCommandResult
.
success
();
}
}
}
}
...
@@ -298,14 +298,14 @@ class PackagesInteractiveGetCommand extends FlutterCommand {
...
@@ -298,14 +298,14 @@ class PackagesInteractiveGetCommand extends FlutterCommand {
@override
@override
String
get
invocation
{
String
get
invocation
{
return
'
${runner.executableName}
pub
$_commandName
[<arguments...>]'
;
return
'
${runner
!
.executableName}
pub
$_commandName
[<arguments...>]'
;
}
}
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
List
<
String
>
rest
=
argResults
.
rest
;
List
<
String
>
rest
=
argResults
!
.
rest
;
final
bool
isHelp
=
rest
.
contains
(
'-h'
)
||
rest
.
contains
(
'--help'
);
final
bool
isHelp
=
rest
.
contains
(
'-h'
)
||
rest
.
contains
(
'--help'
);
String
target
;
String
?
target
;
if
(
rest
.
length
==
1
&&
(
rest
.
single
.
contains
(
'/'
)
||
rest
.
single
.
contains
(
r'\'
)))
{
if
(
rest
.
length
==
1
&&
(
rest
.
single
.
contains
(
'/'
)
||
rest
.
single
.
contains
(
r'\'
)))
{
// For historical reasons, if there is one argument to the command and it contains
// For historical reasons, if there is one argument to the command and it contains
// a multiple-component path (i.e. contains a slash) then we use that to determine
// a multiple-component path (i.e. contains a slash) then we use that to determine
...
@@ -316,7 +316,7 @@ class PackagesInteractiveGetCommand extends FlutterCommand {
...
@@ -316,7 +316,7 @@ class PackagesInteractiveGetCommand extends FlutterCommand {
target
=
findProjectRoot
(
globals
.
fs
);
target
=
findProjectRoot
(
globals
.
fs
);
}
}
FlutterProject
flutterProject
;
FlutterProject
?
flutterProject
;
if
(!
isHelp
)
{
if
(!
isHelp
)
{
if
(
target
==
null
)
{
if
(
target
==
null
)
{
throwToolExit
(
'Expected to find project root in current working directory.'
);
throwToolExit
(
'Expected to find project root in current working directory.'
);
...
@@ -325,7 +325,7 @@ class PackagesInteractiveGetCommand extends FlutterCommand {
...
@@ -325,7 +325,7 @@ class PackagesInteractiveGetCommand extends FlutterCommand {
if
(
flutterProject
.
manifest
.
generateSyntheticPackage
)
{
if
(
flutterProject
.
manifest
.
generateSyntheticPackage
)
{
final
Environment
environment
=
Environment
(
final
Environment
environment
=
Environment
(
artifacts:
globals
.
artifacts
,
artifacts:
globals
.
artifacts
!
,
logger:
globals
.
logger
,
logger:
globals
.
logger
,
cacheDir:
globals
.
cache
.
getRoot
(),
cacheDir:
globals
.
cache
.
getRoot
(),
engineVersion:
globals
.
flutterVersion
.
engineRevision
,
engineVersion:
globals
.
flutterVersion
.
engineRevision
,
...
@@ -351,7 +351,7 @@ class PackagesInteractiveGetCommand extends FlutterCommand {
...
@@ -351,7 +351,7 @@ class PackagesInteractiveGetCommand extends FlutterCommand {
directory:
target
,
directory:
target
,
stdio:
globals
.
stdio
,
stdio:
globals
.
stdio
,
touchesPackageConfig:
!
isHelp
,
touchesPackageConfig:
!
isHelp
,
generateSyntheticPackage:
flutterProject
?.
manifest
?
.
generateSyntheticPackage
??
false
,
generateSyntheticPackage:
flutterProject
?.
manifest
.
generateSyntheticPackage
??
false
,
);
);
await
flutterProject
?.
regeneratePlatformSpecificTooling
();
await
flutterProject
?.
regeneratePlatformSpecificTooling
();
...
...
packages/flutter_tools/lib/src/commands/upgrade.dart
View file @
410d9921
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'../base/common.dart'
;
import
'../base/common.dart'
;
...
@@ -13,6 +11,7 @@ import '../base/process.dart';
...
@@ -13,6 +11,7 @@ import '../base/process.dart';
import
'../cache.dart'
;
import
'../cache.dart'
;
import
'../dart/pub.dart'
;
import
'../dart/pub.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals.dart'
as
globals
;
import
'../persistent_tool_state.dart'
;
import
'../runner/flutter_command.dart'
;
import
'../runner/flutter_command.dart'
;
import
'../version.dart'
;
import
'../version.dart'
;
...
@@ -21,8 +20,8 @@ const String _flutterInstallDocs = 'https://flutter.dev/docs/get-started/install
...
@@ -21,8 +20,8 @@ const String _flutterInstallDocs = 'https://flutter.dev/docs/get-started/install
class
UpgradeCommand
extends
FlutterCommand
{
class
UpgradeCommand
extends
FlutterCommand
{
UpgradeCommand
({
UpgradeCommand
({
@
required
bool
verboseHelp
,
required
bool
verboseHelp
,
UpgradeCommandRunner
commandRunner
,
UpgradeCommandRunner
?
commandRunner
,
})
})
:
_commandRunner
=
commandRunner
??
UpgradeCommandRunner
()
{
:
_commandRunner
=
commandRunner
??
UpgradeCommandRunner
()
{
argParser
argParser
...
@@ -70,7 +69,7 @@ class UpgradeCommand extends FlutterCommand {
...
@@ -70,7 +69,7 @@ class UpgradeCommand extends FlutterCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
{
Future
<
FlutterCommandResult
>
runCommand
()
{
_commandRunner
.
workingDirectory
=
stringArg
(
'working-directory'
)
??
Cache
.
flutterRoot
;
_commandRunner
.
workingDirectory
=
stringArg
(
'working-directory'
)
??
Cache
.
flutterRoot
!
;
return
_commandRunner
.
runCommand
(
return
_commandRunner
.
runCommand
(
force:
boolArg
(
'force'
),
force:
boolArg
(
'force'
),
continueFlow:
boolArg
(
'continue'
),
continueFlow:
boolArg
(
'continue'
),
...
@@ -87,15 +86,15 @@ class UpgradeCommand extends FlutterCommand {
...
@@ -87,15 +86,15 @@ class UpgradeCommand extends FlutterCommand {
@visibleForTesting
@visibleForTesting
class
UpgradeCommandRunner
{
class
UpgradeCommandRunner
{
String
workingDirectory
;
String
?
workingDirectory
;
Future
<
FlutterCommandResult
>
runCommand
({
Future
<
FlutterCommandResult
>
runCommand
({
@
required
bool
force
,
required
bool
force
,
@
required
bool
continueFlow
,
required
bool
continueFlow
,
@
required
bool
testFlow
,
required
bool
testFlow
,
@
required
GitTagVersion
gitTagVersion
,
required
GitTagVersion
gitTagVersion
,
@
required
FlutterVersion
flutterVersion
,
required
FlutterVersion
flutterVersion
,
@
required
bool
verifyOnly
,
required
bool
verifyOnly
,
})
async
{
})
async
{
if
(!
continueFlow
)
{
if
(!
continueFlow
)
{
await
runCommandFirstHalf
(
await
runCommandFirstHalf
(
...
@@ -112,11 +111,11 @@ class UpgradeCommandRunner {
...
@@ -112,11 +111,11 @@ class UpgradeCommandRunner {
}
}
Future
<
void
>
runCommandFirstHalf
({
Future
<
void
>
runCommandFirstHalf
({
@
required
bool
force
,
required
bool
force
,
@
required
GitTagVersion
gitTagVersion
,
required
GitTagVersion
gitTagVersion
,
@
required
FlutterVersion
flutterVersion
,
required
FlutterVersion
flutterVersion
,
@
required
bool
testFlow
,
required
bool
testFlow
,
@
required
bool
verifyOnly
,
required
bool
verifyOnly
,
})
async
{
})
async
{
final
FlutterVersion
upstreamVersion
=
await
fetchLatestVersion
(
localVersion:
flutterVersion
);
final
FlutterVersion
upstreamVersion
=
await
fetchLatestVersion
(
localVersion:
flutterVersion
);
if
(
flutterVersion
.
frameworkRevision
==
upstreamVersion
.
frameworkRevision
)
{
if
(
flutterVersion
.
frameworkRevision
==
upstreamVersion
.
frameworkRevision
)
{
...
@@ -172,11 +171,11 @@ class UpgradeCommandRunner {
...
@@ -172,11 +171,11 @@ class UpgradeCommandRunner {
}
}
void
recordState
(
FlutterVersion
flutterVersion
)
{
void
recordState
(
FlutterVersion
flutterVersion
)
{
final
Channel
channel
=
getChannelForName
(
flutterVersion
.
channel
);
final
Channel
?
channel
=
getChannelForName
(
flutterVersion
.
channel
);
if
(
channel
==
null
)
{
if
(
channel
==
null
)
{
return
;
return
;
}
}
globals
.
persistentToolState
.
updateLastActiveVersion
(
flutterVersion
.
frameworkRevision
,
channel
);
globals
.
persistentToolState
!
.
updateLastActiveVersion
(
flutterVersion
.
frameworkRevision
,
channel
);
}
}
Future
<
void
>
flutterUpgradeContinue
()
async
{
Future
<
void
>
flutterUpgradeContinue
()
async
{
...
@@ -200,12 +199,13 @@ class UpgradeCommandRunner {
...
@@ -200,12 +199,13 @@ class UpgradeCommandRunner {
// re-entrantly with the `--continue` flag
// re-entrantly with the `--continue` flag
Future
<
void
>
runCommandSecondHalf
(
FlutterVersion
flutterVersion
)
async
{
Future
<
void
>
runCommandSecondHalf
(
FlutterVersion
flutterVersion
)
async
{
// Make sure the welcome message re-display is delayed until the end.
// Make sure the welcome message re-display is delayed until the end.
globals
.
persistentToolState
.
setShouldRedisplayWelcomeMessage
(
false
);
final
PersistentToolState
persistentToolState
=
globals
.
persistentToolState
!;
persistentToolState
.
setShouldRedisplayWelcomeMessage
(
false
);
await
precacheArtifacts
();
await
precacheArtifacts
();
await
updatePackages
(
flutterVersion
);
await
updatePackages
(
flutterVersion
);
await
runDoctor
();
await
runDoctor
();
// Force the welcome message to re-display following the upgrade.
// Force the welcome message to re-display following the upgrade.
globals
.
persistentToolState
.
setShouldRedisplayWelcomeMessage
(
true
);
persistentToolState
.
setShouldRedisplayWelcomeMessage
(
true
);
}
}
Future
<
bool
>
hasUncommittedChanges
()
async
{
Future
<
bool
>
hasUncommittedChanges
()
async
{
...
@@ -235,7 +235,8 @@ class UpgradeCommandRunner {
...
@@ -235,7 +235,8 @@ class UpgradeCommandRunner {
/// Exits tool if the tracking remote is not standard.
/// Exits tool if the tracking remote is not standard.
void
verifyStandardRemote
(
FlutterVersion
localVersion
)
{
void
verifyStandardRemote
(
FlutterVersion
localVersion
)
{
// If repositoryUrl of the local version is null, exit
// If repositoryUrl of the local version is null, exit
if
(
localVersion
.
repositoryUrl
==
null
)
{
final
String
?
repositoryUrl
=
localVersion
.
repositoryUrl
;
if
(
repositoryUrl
==
null
)
{
throwToolExit
(
throwToolExit
(
'Unable to upgrade Flutter: The tool could not determine the remote '
'Unable to upgrade Flutter: The tool could not determine the remote '
'upstream which is being tracked by the SDK.
\n
'
'upstream which is being tracked by the SDK.
\n
'
...
@@ -244,7 +245,7 @@ class UpgradeCommandRunner {
...
@@ -244,7 +245,7 @@ class UpgradeCommandRunner {
}
}
// Strip `.git` suffix before comparing the remotes
// Strip `.git` suffix before comparing the remotes
final
String
trackingUrl
=
stripDotGit
(
localVersion
.
repositoryUrl
);
final
String
trackingUrl
=
stripDotGit
(
repositoryUrl
);
final
String
flutterGitUrl
=
stripDotGit
(
globals
.
flutterGit
);
final
String
flutterGitUrl
=
stripDotGit
(
globals
.
flutterGit
);
// Exempt the official flutter git SSH remote from this check
// Exempt the official flutter git SSH remote from this check
...
@@ -287,18 +288,18 @@ class UpgradeCommandRunner {
...
@@ -287,18 +288,18 @@ class UpgradeCommandRunner {
// URLs without ".git" suffix will remain unaffected.
// URLs without ".git" suffix will remain unaffected.
String
stripDotGit
(
String
url
)
{
String
stripDotGit
(
String
url
)
{
final
RegExp
pattern
=
RegExp
(
r'(.*)(\.git)$'
);
final
RegExp
pattern
=
RegExp
(
r'(.*)(\.git)$'
);
final
RegExpMatch
match
=
pattern
.
firstMatch
(
url
);
final
RegExpMatch
?
match
=
pattern
.
firstMatch
(
url
);
if
(
match
==
null
)
{
if
(
match
==
null
)
{
return
url
;
return
url
;
}
}
return
match
.
group
(
1
);
return
match
.
group
(
1
)
!
;
}
}
/// Returns the remote HEAD flutter version.
/// Returns the remote HEAD flutter version.
///
///
/// Exits tool if HEAD isn't pointing to a branch, or there is no upstream.
/// Exits tool if HEAD isn't pointing to a branch, or there is no upstream.
Future
<
FlutterVersion
>
fetchLatestVersion
({
Future
<
FlutterVersion
>
fetchLatestVersion
({
@
required
FlutterVersion
localVersion
,
required
FlutterVersion
localVersion
,
})
async
{
})
async
{
String
revision
;
String
revision
;
try
{
try
{
...
@@ -380,14 +381,13 @@ class UpgradeCommandRunner {
...
@@ -380,14 +381,13 @@ class UpgradeCommandRunner {
Future
<
void
>
updatePackages
(
FlutterVersion
flutterVersion
)
async
{
Future
<
void
>
updatePackages
(
FlutterVersion
flutterVersion
)
async
{
globals
.
printStatus
(
''
);
globals
.
printStatus
(
''
);
globals
.
printStatus
(
flutterVersion
.
toString
());
globals
.
printStatus
(
flutterVersion
.
toString
());
final
String
projectRoot
=
findProjectRoot
(
globals
.
fs
);
final
String
?
projectRoot
=
findProjectRoot
(
globals
.
fs
);
if
(
projectRoot
!=
null
)
{
if
(
projectRoot
!=
null
)
{
globals
.
printStatus
(
''
);
globals
.
printStatus
(
''
);
await
pub
.
get
(
await
pub
.
get
(
context:
PubContext
.
pubUpgrade
,
context:
PubContext
.
pubUpgrade
,
directory:
projectRoot
,
directory:
projectRoot
,
upgrade:
true
,
upgrade:
true
,
generateSyntheticPackage:
false
,
);
);
}
}
}
}
...
...
packages/flutter_tools/lib/src/dart/pub.dart
View file @
410d9921
...
@@ -101,7 +101,7 @@ abstract class Pub {
...
@@ -101,7 +101,7 @@ abstract class Pub {
bool
upgrade
=
false
,
bool
upgrade
=
false
,
bool
offline
=
false
,
bool
offline
=
false
,
bool
generateSyntheticPackage
=
false
,
bool
generateSyntheticPackage
=
false
,
String
flutterRootOverride
,
String
?
flutterRootOverride
,
bool
checkUpToDate
=
false
,
bool
checkUpToDate
=
false
,
bool
shouldSkipThirdPartyGenerator
=
true
,
bool
shouldSkipThirdPartyGenerator
=
true
,
bool
printProgress
=
true
,
bool
printProgress
=
true
,
...
@@ -135,7 +135,7 @@ abstract class Pub {
...
@@ -135,7 +135,7 @@ abstract class Pub {
/// stdout/stderr stream of pub to the corresponding streams of this process.
/// stdout/stderr stream of pub to the corresponding streams of this process.
Future
<
void
>
interactively
(
Future
<
void
>
interactively
(
List
<
String
>
arguments
,
{
List
<
String
>
arguments
,
{
String
directory
,
String
?
directory
,
required
io
.
Stdio
stdio
,
required
io
.
Stdio
stdio
,
bool
touchesPackageConfig
=
false
,
bool
touchesPackageConfig
=
false
,
bool
generateSyntheticPackage
=
false
,
bool
generateSyntheticPackage
=
false
,
...
...
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