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
99b44599
Unverified
Commit
99b44599
authored
Apr 08, 2019
by
Jonah Williams
Committed by
GitHub
Apr 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow disabling experimental commands, devices on stable branch (#30153)
parent
294d7ea0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
3 deletions
+68
-3
build_web.dart
packages/flutter_tools/lib/src/commands/build_web.dart
+3
-0
desktop.dart
packages/flutter_tools/lib/src/desktop.dart
+2
-1
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+12
-0
version.dart
packages/flutter_tools/lib/src/version.dart
+5
-0
web_device.dart
packages/flutter_tools/lib/src/web/web_device.dart
+2
-1
flutter_command_test.dart
packages/flutter_tools/test/runner/flutter_command_test.dart
+40
-0
context.dart
packages/flutter_tools/test/src/context.dart
+4
-1
No files found.
packages/flutter_tools/lib/src/commands/build_web.dart
View file @
99b44599
...
...
@@ -31,6 +31,9 @@ class BuildWebCommand extends BuildSubCommand {
@override
bool
get
hidden
=>
true
;
@override
bool
get
isExperimental
=>
true
;
@override
final
String
description
=
'(EXPERIMENTAL) build a web application bundle.'
;
...
...
packages/flutter_tools/lib/src/desktop.dart
View file @
99b44599
...
...
@@ -3,11 +3,12 @@
// found in the LICENSE file.
import
'base/platform.dart'
;
import
'version.dart'
;
// Only launch or display desktop embedding devices if
// `FLUTTER_DESKTOP_EMBEDDING` environment variable is set to true.
bool
get
flutterDesktopEnabled
{
_flutterDesktopEnabled
??=
platform
.
environment
[
'FLUTTER_DESKTOP_EMBEDDING'
]?.
toLowerCase
()
==
'true'
;
return
_flutterDesktopEnabled
;
return
_flutterDesktopEnabled
&&
!
FlutterVersion
.
instance
.
isStable
;
}
bool
_flutterDesktopEnabled
;
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
99b44599
...
...
@@ -27,6 +27,7 @@ import '../doctor.dart';
import
'../globals.dart'
;
import
'../project.dart'
;
import
'../usage.dart'
;
import
'../version.dart'
;
import
'flutter_command_runner.dart'
;
export
'../cache.dart'
show
DevelopmentArtifact
;
...
...
@@ -464,6 +465,11 @@ abstract class FlutterCommand extends Command<void> {
}
}
/// Whether this feature should not be usable on stable branches.
///
/// Defaults to false, meaning it is usable.
bool
get
isExperimental
=>
false
;
/// Additional usage values to be sent with the usage ping.
Future
<
Map
<
String
,
String
>>
get
usageValues
async
=>
const
<
String
,
String
>{};
...
...
@@ -635,6 +641,12 @@ abstract class FlutterCommand extends Command<void> {
@protected
@mustCallSuper
Future
<
void
>
validateCommand
()
async
{
// If we're on a stable branch, then don't allow the usage of
// "experimental" features.
if
(
isExperimental
&&
FlutterVersion
.
instance
.
isStable
)
{
throwToolExit
(
'Experimental feature
$name
is not supported on stable branches'
);
}
if
(
_requiresPubspecYaml
&&
!
PackageMap
.
isUsingCustomPackagesPath
)
{
// Don't expect a pubspec.yaml file if the user passed in an explicit .packages file path.
if
(!
fs
.
isFileSync
(
'pubspec.yaml'
))
{
...
...
packages/flutter_tools/lib/src/version.dart
View file @
99b44599
...
...
@@ -32,6 +32,11 @@ class FlutterVersion {
return
_repositoryUrl
;
}
/// Whether we are currently on the stable branch.
bool
get
isStable
{
return
getBranchName
()
==
'stable'
;
}
static
const
Set
<
String
>
officialChannels
=
<
String
>{
'master'
,
'dev'
,
...
...
packages/flutter_tools/lib/src/web/web_device.dart
View file @
99b44599
...
...
@@ -13,6 +13,7 @@ import '../build_info.dart';
import
'../device.dart'
;
import
'../globals.dart'
;
import
'../project.dart'
;
import
'../version.dart'
;
import
'../web/compile.dart'
;
ChromeLauncher
get
chromeLauncher
=>
context
[
ChromeLauncher
];
...
...
@@ -21,7 +22,7 @@ ChromeLauncher get chromeLauncher => context[ChromeLauncher];
/// environment variable is set to true.
bool
get
flutterWebEnabled
{
_flutterWebEnabled
=
platform
.
environment
[
'FLUTTER_WEB'
]?.
toLowerCase
()
==
'true'
;
return
_flutterWebEnabled
;
return
_flutterWebEnabled
&&
!
FlutterVersion
.
instance
.
isStable
;
}
bool
_flutterWebEnabled
;
...
...
packages/flutter_tools/test/runner/flutter_command_test.dart
View file @
99b44599
...
...
@@ -7,6 +7,7 @@ import 'package:flutter_tools/src/base/time.dart';
import
'package:flutter_tools/src/usage.dart'
;
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/runner/flutter_command.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:mockito/mockito.dart'
;
import
'../src/common.dart'
;
...
...
@@ -155,4 +156,43 @@ void main() {
});
});
group
(
'Experimental commands'
,
()
{
final
MockVersion
stableVersion
=
MockVersion
();
final
MockVersion
betaVersion
=
MockVersion
();
final
FakeCommand
fakeCommand
=
FakeCommand
();
when
(
stableVersion
.
isStable
).
thenReturn
(
true
);
when
(
betaVersion
.
isStable
).
thenReturn
(
false
);
testUsingContext
(
'Can be disabled on stable branch'
,
()
async
{
expect
(()
=>
fakeCommand
.
run
(),
throwsA
(
isA
<
ToolExit
>()));
},
overrides:
<
Type
,
Generator
>{
FlutterVersion:
()
=>
stableVersion
,
});
testUsingContext
(
'Works normally on regular branches'
,
()
async
{
expect
(
fakeCommand
.
run
(),
completes
);
},
overrides:
<
Type
,
Generator
>{
FlutterVersion:
()
=>
betaVersion
,
});
});
}
class
FakeCommand
extends
FlutterCommand
{
@override
String
get
description
=>
null
;
@override
String
get
name
=>
'fake'
;
@override
bool
get
isExperimental
=>
true
;
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
return
null
;
}
}
class
MockVersion
extends
Mock
implements
FlutterVersion
{}
packages/flutter_tools/test/src/context.dart
View file @
99b44599
...
...
@@ -304,7 +304,10 @@ class MockXcodeProjectInterpreter implements XcodeProjectInterpreter {
}
}
class
MockFlutterVersion
extends
Mock
implements
FlutterVersion
{}
class
MockFlutterVersion
extends
Mock
implements
FlutterVersion
{
@override
bool
get
isStable
=>
false
;
}
class
MockClock
extends
Mock
implements
SystemClock
{}
...
...
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