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
2a36ad31
Unverified
Commit
2a36ad31
authored
Sep 19, 2019
by
Jonah Williams
Committed by
GitHub
Sep 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure Flutter for Web debug builds are only accessible through Flutter run (#40783)
parent
a36f809e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
7 deletions
+27
-7
build_web.dart
packages/flutter_tools/lib/src/commands/build_web.dart
+4
-1
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+14
-6
build_web_test.dart
...ter_tools/test/general.shard/commands/build_web_test.dart
+9
-0
No files found.
packages/flutter_tools/lib/src/commands/build_web.dart
View file @
2a36ad31
...
...
@@ -17,7 +17,7 @@ class BuildWebCommand extends BuildSubCommand {
BuildWebCommand
()
{
usesTargetOption
();
usesPubOption
();
addBuildModeFlags
();
addBuildModeFlags
(
excludeDebug:
true
);
argParser
.
addFlag
(
'web-initialize-platform'
,
defaultsTo:
true
,
negatable:
true
,
...
...
@@ -50,6 +50,9 @@ class BuildWebCommand extends BuildSubCommand {
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
final
String
target
=
argResults
[
'target'
];
final
BuildInfo
buildInfo
=
getBuildInfo
();
if
(
buildInfo
.
isDebug
)
{
throwToolExit
(
'debug builds cannot be built directly for the web. Try using "flutter run"'
);
}
await
buildWeb
(
flutterProject
,
target
,
buildInfo
,
argResults
[
'web-initialize-platform'
]);
return
null
;
}
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
2a36ad31
...
...
@@ -126,6 +126,8 @@ abstract class FlutterCommand extends Command<void> {
bool
get
shouldUpdateCache
=>
true
;
bool
_excludeDebug
=
false
;
BuildMode
_defaultBuildMode
;
void
requiresPubspecYaml
()
{
...
...
@@ -263,12 +265,17 @@ abstract class FlutterCommand extends Command<void> {
'Normally there
\'
s only one, but when adding Flutter to a pre-existing app it
\'
s possible to create multiple.'
);
}
void
addBuildModeFlags
({
bool
defaultToRelease
=
true
,
bool
verboseHelp
=
false
})
{
void
addBuildModeFlags
({
bool
defaultToRelease
=
true
,
bool
verboseHelp
=
false
,
bool
excludeDebug
=
false
})
{
// A release build must be the default if a debug build is not possible.
assert
(
defaultToRelease
||
!
excludeDebug
);
_excludeDebug
=
excludeDebug
;
defaultBuildMode
=
defaultToRelease
?
BuildMode
.
release
:
BuildMode
.
debug
;
argParser
.
addFlag
(
'debug'
,
negatable:
false
,
help:
'Build a debug version of your app
${defaultToRelease ? '' : ' (default mode)'}
.'
);
if
(!
excludeDebug
)
{
argParser
.
addFlag
(
'debug'
,
negatable:
false
,
help:
'Build a debug version of your app
${defaultToRelease ? '' : ' (default mode)'}
.'
);
}
argParser
.
addFlag
(
'profile'
,
negatable:
false
,
help:
'Build a version of your app specialized for performance profiling.'
);
...
...
@@ -312,11 +319,12 @@ abstract class FlutterCommand extends Command<void> {
}
BuildMode
getBuildMode
()
{
final
List
<
bool
>
modeFlags
=
<
bool
>[
argResults
[
'debug'
],
argResults
[
'profile'
],
argResults
[
'release'
]];
final
bool
debugResult
=
_excludeDebug
?
false
:
argResults
[
'debug'
];
final
List
<
bool
>
modeFlags
=
<
bool
>[
debugResult
,
argResults
[
'profile'
],
argResults
[
'release'
]];
if
(
modeFlags
.
where
((
bool
flag
)
=>
flag
).
length
>
1
)
{
throw
UsageException
(
'Only one of --debug, --profile, or --release can be specified.'
,
null
);
}
if
(
argResults
[
'debug'
]
)
{
if
(
debugResult
)
{
return
BuildMode
.
debug
;
}
if
(
argResults
[
'profile'
])
{
...
...
packages/flutter_tools/test/general.shard/commands/build_web_test.dart
View file @
2a36ad31
...
...
@@ -92,6 +92,15 @@ void main() {
);
}));
test
(
'Refuses to build a debug build for web'
,
()
=>
testbed
.
run
(()
async
{
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
BuildCommand
());
expect
(()
=>
runner
.
run
(<
String
>[
'build'
,
'web'
,
'--debug'
]),
throwsA
(
isInstanceOf
<
UsageException
>()));
},
overrides:
<
Type
,
Generator
>{
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
true
),
}));
test
(
'Refuses to build for web when feature is disabled'
,
()
=>
testbed
.
run
(()
async
{
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
BuildCommand
());
...
...
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