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
83aa065f
Unverified
Commit
83aa065f
authored
May 02, 2019
by
Jonah Williams
Committed by
GitHub
May 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add commands to swap dart imports for local development (#31925)
parent
e17f9e8f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
3 deletions
+119
-3
web_swap.dart
packages/flutter_tools/bin/web_swap.dart
+116
-0
flutter_command_runner.dart
.../flutter_tools/lib/src/runner/flutter_command_runner.dart
+3
-3
No files found.
packages/flutter_tools/bin/web_swap.dart
0 → 100644
View file @
83aa065f
// Copyright 2019 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
'package:args/args.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/context_runner.dart'
;
import
'package:flutter_tools/src/globals.dart'
;
import
'package:flutter_tools/src/runner/flutter_command_runner.dart'
;
final
ArgParser
argParser
=
ArgParser
()
..
addFlag
(
'back'
,
help:
'Swap back to dart:ui from web_ui'
,
defaultsTo:
false
);
/// Swap the dart:ui imports with web_ui for local development.
///
/// This is only intended as a temporary bridge to the new development
/// workflow and will be removed at a later time.
Future
<
void
>
main
(
List
<
String
>
arguments
)
async
{
final
ArgResults
results
=
argParser
.
parse
(
arguments
);
await
runInContext
(()
{
// Normally this is initialized by the command runner.
Cache
.
flutterRoot
=
FlutterCommandRunner
.
defaultFlutterRoot
;
printError
(
'WARNING: This is only intended for use by flutter contributors.'
' Running this command will alter the code in your flutter checkout.'
);
final
String
engineDirectory
=
fs
.
path
.
join
(
Cache
.
flutterRoot
,
'..'
,
'engine'
,
'src'
,
'flutter'
,
'lib'
,
'stub_ui'
);
final
String
flutterPath
=
fs
.
path
.
join
(
Cache
.
flutterRoot
,
'packages'
,
'flutter'
);
final
String
flutterTestPath
=
fs
.
path
.
join
(
Cache
.
flutterRoot
,
'packages'
,
'flutter_test'
);
final
List
<
List
<
Pattern
>>
codePatterns
=
<
List
<
Pattern
>>[
<
Pattern
>[
'import
\'
dart:ui
\'
'
,
'import
\'
package:flutter_web_ui/ui.dart
\'
'
],
<
Pattern
>[
'export
\'
dart:ui
\'
'
,
'export
\'
package:flutter_web_ui/ui.dart
\'
'
],
<
Pattern
>[
'export
\'
bitfield.dart
\'
if (dart.library.html)
\'
bitfield_unsupported.dart
\'
;'
,
'export
\'
bitfield_unsupported.dart
\'
;'
]
];
final
List
<
List
<
Pattern
>>
configPatterns
=
<
List
<
Pattern
>>[
<
Pattern
>[
'''
sky_engine:
sdk: flutter
'''
,
'''
flutter_web_ui:
path:
$engineDirectory
'''
],
<
Pattern
>[
'''
flutter:
sdk: flutter
'''
,
'''
flutter:
path:
$flutterPath
'''
],
<
Pattern
>[
'''
flutter_driver:
sdk: flutter
'''
,
'''
# flutter_driver:
# sdk: flutter
'''
],
<
Pattern
>[
'''
flutter_test:
sdk: flutter
'''
,
'''
flutter_test:
path:
$flutterTestPath
build_runner: '
>=
0.8
.
10
<
2.0
.
0
'
build_web_compilers: '
>=
0.3
.
6
<
2.0
.
0
'
'''
],
<
Pattern
>[
r''
'
flutter_goldens:
sdk: flutter
'''
,
r''
'
# flutter_goldens:
# sdk: flutter
'''
],
];
final
Iterable
<
File
>
searchFiles
=
<
Directory
>[
fs
.
directory
(
fs
.
path
.
join
(
Cache
.
flutterRoot
,
'packages'
)),
fs
.
directory
(
fs
.
path
.
join
(
Cache
.
flutterRoot
,
'examples'
)),
].
expand
((
Directory
directory
)
=>
directory
.
listSync
(
recursive:
true
))
.
whereType
<
File
>()
.
where
((
File
file
)
=>
file
.
path
.
endsWith
(
'.dart'
)
||
file
.
path
.
endsWith
(
'pubspec.yaml'
));
for
(
File
file
in
searchFiles
)
{
String
contents
=
file
.
readAsStringSync
();
final
List
<
List
<
Pattern
>>
patterns
=
file
.
path
.
endsWith
(
'.dart'
)
?
codePatterns
:
configPatterns
;
if
(
file
.
path
.
endsWith
(
'.dart'
))
{
for
(
List
<
Pattern
>
patterns
in
patterns
)
{
contents
=
results
[
'back'
]
?
contents
.
replaceAll
(
patterns
.
last
,
patterns
.
first
)
:
contents
.
replaceAll
(
patterns
.
first
,
patterns
.
last
);
}
file
.
writeAsStringSync
(
contents
);
}
}
});
}
\ No newline at end of file
packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
View file @
83aa065f
...
@@ -178,7 +178,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
...
@@ -178,7 +178,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
return
'
${wrapText(description)}
\n\n
$usageWithoutDescription
'
;
return
'
${wrapText(description)}
\n\n
$usageWithoutDescription
'
;
}
}
static
String
get
_
defaultFlutterRoot
{
static
String
get
defaultFlutterRoot
{
if
(
platform
.
environment
.
containsKey
(
kFlutterRootEnvironmentVariableName
))
if
(
platform
.
environment
.
containsKey
(
kFlutterRootEnvironmentVariableName
))
return
platform
.
environment
[
kFlutterRootEnvironmentVariableName
];
return
platform
.
environment
[
kFlutterRootEnvironmentVariableName
];
try
{
try
{
...
@@ -342,7 +342,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
...
@@ -342,7 +342,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
// We must set Cache.flutterRoot early because other features use it (e.g.
// We must set Cache.flutterRoot early because other features use it (e.g.
// enginePath's initializer uses it).
// enginePath's initializer uses it).
final
String
flutterRoot
=
topLevelResults
[
'flutter-root'
]
??
_
defaultFlutterRoot
;
final
String
flutterRoot
=
topLevelResults
[
'flutter-root'
]
??
defaultFlutterRoot
;
Cache
.
flutterRoot
=
fs
.
path
.
normalize
(
fs
.
path
.
absolute
(
flutterRoot
));
Cache
.
flutterRoot
=
fs
.
path
.
normalize
(
fs
.
path
.
absolute
(
flutterRoot
));
// Set up the tooling configuration.
// Set up the tooling configuration.
...
@@ -478,7 +478,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
...
@@ -478,7 +478,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
}
}
static
void
initFlutterRoot
()
{
static
void
initFlutterRoot
()
{
Cache
.
flutterRoot
??=
_
defaultFlutterRoot
;
Cache
.
flutterRoot
??=
defaultFlutterRoot
;
}
}
/// Get the root directories of the repo - the directories containing Dart packages.
/// Get the root directories of the repo - the directories containing Dart packages.
...
...
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