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
106b8eb9
Unverified
Commit
106b8eb9
authored
Nov 20, 2019
by
Jonah Williams
Committed by
GitHub
Nov 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Reduce some direct package:archive usage (#44608)" (#45291)
This reverts commit
6b5634fe
.
parent
6b5634fe
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
89 deletions
+121
-89
os.dart
packages/flutter_tools/lib/src/base/os.dart
+0
-1
web_fs.dart
packages/flutter_tools/lib/src/build_runner/web_fs.dart
+28
-0
intellij.dart
packages/flutter_tools/lib/src/intellij/intellij.dart
+10
-16
intellij_test.dart
...tter_tools/test/general.shard/intellij/intellij_test.dart
+83
-72
No files found.
packages/flutter_tools/lib/src/base/os.dart
View file @
106b8eb9
...
...
@@ -249,7 +249,6 @@ class _WindowsUtils extends OperatingSystemUtils {
@override
void
zip
(
Directory
data
,
File
zipFile
)
{
// TODO(jonahwilliams): investigate whether we can remove this dependency with https://github.com/flutter/flutter/issues/45278
final
Archive
archive
=
Archive
();
for
(
FileSystemEntity
entity
in
data
.
listSync
(
recursive:
true
))
{
if
(
entity
is
!
File
)
{
...
...
packages/flutter_tools/lib/src/build_runner/web_fs.dart
View file @
106b8eb9
...
...
@@ -5,6 +5,7 @@
import
'dart:async'
;
import
'dart:typed_data'
;
import
'package:archive/archive.dart'
;
import
'package:build_daemon/client.dart'
;
import
'package:build_daemon/constants.dart'
as
daemon
;
import
'package:build_daemon/data/build_status.dart'
;
...
...
@@ -406,6 +407,33 @@ class DebugAssetServer extends AssetServer {
return
Response
.
ok
(
file
.
readAsBytesSync
(),
headers:
<
String
,
String
>{
'Content-Type'
:
'text/javascript'
,
});
}
else
if
(
request
.
url
.
path
.
endsWith
(
'part.js'
))
{
// Lazily unpack any deferred imports in release/profile mode. These are
// placed into an archive by build_runner, and are named based on the main
// entrypoint + a "part" suffix (Though the actual names are arbitrary).
// To make this easier to deal with they are copied into a temp directory.
if
(
partFiles
==
null
)
{
final
File
dart2jsArchive
=
fs
.
file
(
fs
.
path
.
join
(
flutterProject
.
dartTool
.
path
,
'build'
,
'flutter_web'
,
'
${flutterProject.manifest.appName}
'
,
'lib'
,
'
${targetBaseName}
_web_entrypoint.dart.js.tar.gz'
,
));
if
(
dart2jsArchive
.
existsSync
())
{
final
Archive
archive
=
TarDecoder
().
decodeBytes
(
dart2jsArchive
.
readAsBytesSync
());
partFiles
=
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_tool.'
)
..
createSync
();
for
(
ArchiveFile
file
in
archive
)
{
partFiles
.
childFile
(
file
.
name
).
writeAsBytesSync
(
file
.
content
as
List
<
int
>);
}
}
}
final
String
fileName
=
fs
.
path
.
basename
(
request
.
url
.
path
);
return
Response
.
ok
(
partFiles
.
childFile
(
fileName
).
readAsBytesSync
(),
headers:
<
String
,
String
>{
'Content-Type'
:
'text/javascript'
,
});
}
else
if
(
request
.
url
.
path
.
contains
(
'require.js'
))
{
final
File
file
=
fs
.
file
(
fs
.
path
.
join
(
artifacts
.
getArtifactPath
(
Artifact
.
engineDartSdkPath
),
...
...
packages/flutter_tools/lib/src/intellij/intellij.dart
View file @
106b8eb9
...
...
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:archive/archive.dart'
;
import
'../base/file_system.dart'
;
import
'../base/os.dart'
;
import
'../base/version.dart'
;
import
'../convert.dart'
;
import
'../doctor.dart'
;
import
'../globals.dart'
;
class
IntelliJPlugins
{
IntelliJPlugins
(
this
.
pluginsPath
);
...
...
@@ -55,25 +56,18 @@ class IntelliJPlugins {
final
String
jarPath
=
packageName
.
endsWith
(
'.jar'
)
?
fs
.
path
.
join
(
pluginsPath
,
packageName
)
:
fs
.
path
.
join
(
pluginsPath
,
packageName
,
'lib'
,
'
$packageName
.jar'
);
// TODO(danrubel): look for a better way to extract a single 2K file from the zip
// rather than reading the entire file into memory.
try
{
final
Directory
tempDirectory
=
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_tools_intellij.'
)
..
createSync
(
recursive:
true
);
os
.
unzip
(
fs
.
file
(
jarPath
),
tempDirectory
);
final
File
file
=
tempDirectory
.
childDirectory
(
'META-INF'
)
.
childFile
(
'plugin.xml'
);
final
String
content
=
file
.
readAsStringSync
();
final
Archive
archive
=
ZipDecoder
().
decodeBytes
(
fs
.
file
(
jarPath
).
readAsBytesSync
());
final
ArchiveFile
file
=
archive
.
findFile
(
'META-INF/plugin.xml'
);
final
String
content
=
utf8
.
decode
(
file
.
content
as
List
<
int
>);
const
String
versionStartTag
=
'<version>'
;
final
int
start
=
content
.
indexOf
(
versionStartTag
);
final
int
end
=
content
.
indexOf
(
'</version>'
,
start
);
try
{
tempDirectory
.
deleteSync
(
recursive:
true
);
}
on
Exception
catch
(
_
)
{
printTrace
(
'Failed to delete temp directory:
${tempDirectory?.path}
'
);
}
return
content
.
substring
(
start
+
versionStartTag
.
length
,
end
);
}
on
Exception
catch
(
_
)
{
}
catch
(
_
)
{
return
null
;
}
}
...
...
packages/flutter_tools/test/general.shard/intellij/intellij_test.dart
View file @
106b8eb9
// Copyright 2018 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:convert'
;
import
'package:archive/archive.dart'
;
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/doctor.dart'
;
import
'package:flutter_tools/src/intellij/intellij.dart'
;
import
'package:mockito/mockito.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
const
String
dartPluginContents
=
'''<idea-plugin version="2">
<name>Dart</name>
<version>162.2485</version>
</idea-plugin>
'''
;
const
String
flutterPluginContents
=
r''
'
<idea-plugin version="2">
<name>Flutter</name>
<version>0.1.3</version>
</idea-plugin>
'''
;
void
main
(
)
{
testUsingContext
(
'IntelliJ plugins found'
,
()
async
{
fs
.
directory
(
fs
.
path
.
join
(
_kPluginsPath
,
'Dart'
))
.
createSync
(
recursive:
true
);
fs
.
file
(
fs
.
path
.
join
(
_kPluginsPath
,
'flutter-intellij.jar'
))
.
createSync
(
recursive:
true
);
when
(
os
.
unzip
(
any
,
any
)).
thenAnswer
((
Invocation
invocation
)
{
final
File
file
=
invocation
.
positionalArguments
.
first
as
File
;
final
Directory
destination
=
invocation
.
positionalArguments
.
last
as
Directory
;
destination
.
childDirectory
(
'META-INF'
)
.
childFile
(
'plugin.xml'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
file
.
path
.
contains
(
'Dart'
)
?
dartPluginContents
:
flutterPluginContents
);
});
FileSystem
fs
;
final
IntelliJPlugins
plugins
=
IntelliJPlugins
(
_kPluginsPath
);
void
writeFileCreatingDirectories
(
String
path
,
List
<
int
>
bytes
)
{
final
File
file
=
fs
.
file
(
path
);
file
.
parent
.
createSync
(
recursive:
true
);
file
.
writeAsBytesSync
(
bytes
);
}
final
List
<
ValidationMessage
>
messages
=
<
ValidationMessage
>[];
plugins
.
validatePackage
(
messages
,
<
String
>[
'Dart'
],
'Dart'
);
plugins
.
validatePackage
(
messages
,
<
String
>[
'flutter-intellij'
,
'flutter-intellij.jar'
],
'Flutter'
,
minVersion:
IntelliJPlugins
.
kMinFlutterPluginVersion
);
setUp
(()
{
fs
=
MemoryFileSystem
();
});
ValidationMessage
message
=
messages
.
firstWhere
((
ValidationMessage
m
)
=>
m
.
message
.
startsWith
(
'Dart '
));
group
(
'IntelliJ'
,
()
{
group
(
'plugins'
,
()
{
testUsingContext
(
'found'
,
()
async
{
final
IntelliJPlugins
plugins
=
IntelliJPlugins
(
_kPluginsPath
);
expect
(
message
.
message
,
'Dart plugin version 162.2485'
);
message
=
messages
.
firstWhere
(
(
ValidationMessage
m
)
=>
m
.
message
.
startsWith
(
'Flutter '
));
final
Archive
dartJarArchive
=
buildSingleFileArchive
(
'META-INF/plugin.xml'
,
r''
'
<idea-plugin version="2">
<name>Dart</name>
<version>162.2485</version>
</idea-plugin>
'''
);
writeFileCreatingDirectories
(
fs
.
path
.
join
(
_kPluginsPath
,
'Dart'
,
'lib'
,
'Dart.jar'
),
ZipEncoder
().
encode
(
dartJarArchive
));
expect
(
message
.
message
,
contains
(
'Flutter plugin version 0.1.3'
));
expect
(
message
.
message
,
contains
(
'recommended minimum version'
));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
OperatingSystemUtils:
()
=>
MockOperatingSystemUtils
(),
final
Archive
flutterJarArchive
=
buildSingleFileArchive
(
'META-INF/plugin.xml'
,
r''
'
<idea-plugin version="2">
<name>Flutter</name>
<version>0.1.3</version>
</idea-plugin>
'''
);
writeFileCreatingDirectories
(
fs
.
path
.
join
(
_kPluginsPath
,
'flutter-intellij.jar'
),
ZipEncoder
().
encode
(
flutterJarArchive
));
final
List
<
ValidationMessage
>
messages
=
<
ValidationMessage
>[];
plugins
.
validatePackage
(
messages
,
<
String
>[
'Dart'
],
'Dart'
);
plugins
.
validatePackage
(
messages
,
<
String
>[
'flutter-intellij'
,
'flutter-intellij.jar'
],
'Flutter'
,
minVersion:
IntelliJPlugins
.
kMinFlutterPluginVersion
);
ValidationMessage
message
=
messages
.
firstWhere
((
ValidationMessage
m
)
=>
m
.
message
.
startsWith
(
'Dart '
));
expect
(
message
.
message
,
'Dart plugin version 162.2485'
);
message
=
messages
.
firstWhere
(
(
ValidationMessage
m
)
=>
m
.
message
.
startsWith
(
'Flutter '
));
expect
(
message
.
message
,
contains
(
'Flutter plugin version 0.1.3'
));
expect
(
message
.
message
,
contains
(
'recommended minimum version'
));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
testUsingContext
(
'not found'
,
()
async
{
final
IntelliJPlugins
plugins
=
IntelliJPlugins
(
_kPluginsPath
);
final
List
<
ValidationMessage
>
messages
=
<
ValidationMessage
>[];
plugins
.
validatePackage
(
messages
,
<
String
>[
'Dart'
],
'Dart'
);
plugins
.
validatePackage
(
messages
,
<
String
>[
'flutter-intellij'
,
'flutter-intellij.jar'
],
'Flutter'
,
minVersion:
IntelliJPlugins
.
kMinFlutterPluginVersion
);
ValidationMessage
message
=
messages
.
firstWhere
((
ValidationMessage
m
)
=>
m
.
message
.
startsWith
(
'Dart '
));
expect
(
message
.
message
,
contains
(
'Dart plugin not installed'
));
message
=
messages
.
firstWhere
(
(
ValidationMessage
m
)
=>
m
.
message
.
startsWith
(
'Flutter '
));
expect
(
message
.
message
,
contains
(
'Flutter plugin not installed'
));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
});
});
}
testUsingContext
(
'IntelliJ plugins not found'
,
()
async
{
final
IntelliJPlugins
plugins
=
IntelliJPlugins
(
_kPluginsPath
);
final
List
<
ValidationMessage
>
messages
=
<
ValidationMessage
>[];
plugins
.
validatePackage
(
messages
,
<
String
>[
'Dart'
],
'Dart'
);
plugins
.
validatePackage
(
messages
,
<
String
>[
'flutter-intellij'
,
'flutter-intellij.jar'
],
'Flutter'
,
minVersion:
IntelliJPlugins
.
kMinFlutterPluginVersion
);
ValidationMessage
message
=
messages
.
firstWhere
((
ValidationMessage
m
)
=>
m
.
message
.
startsWith
(
'Dart '
));
const
String
_kPluginsPath
=
'/data/intellij/plugins'
;
expect
(
message
.
message
,
contains
(
'Dart plugin not installed'
));
Archive
buildSingleFileArchive
(
String
path
,
String
content
)
{
final
Archive
archive
=
Archive
();
message
=
messages
.
firstWhere
(
(
ValidationMessage
m
)
=>
m
.
message
.
startsWith
(
'Flutter '
));
final
List
<
int
>
bytes
=
utf8
.
encode
(
content
);
archive
.
addFile
(
ArchiveFile
(
path
,
bytes
.
length
,
bytes
));
expect
(
message
.
message
,
contains
(
'Flutter plugin not installed'
));
},
overrides:
<
Type
,
Generator
>{
OperatingSystemUtils:
()
=>
MockOperatingSystemUtils
(),
FileSystem:
()
=>
MemoryFileSystem
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
return
archive
;
}
class
MockOperatingSystemUtils
extends
Mock
implements
OperatingSystemUtils
{}
const
String
_kPluginsPath
=
'/data/intellij/plugins'
;
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