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
bf89943d
Unverified
Commit
bf89943d
authored
Jan 16, 2021
by
Jonas Finnemann Jensen
Committed by
GitHub
Jan 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pub upgrade to work with new arguments (#74060)
parent
97e82d79
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
114 additions
and
2 deletions
+114
-2
packages.dart
packages/flutter_tools/lib/src/commands/packages.dart
+85
-1
pub.dart
packages/flutter_tools/lib/src/dart/pub.dart
+21
-0
packages_test.dart
...er_tools/test/commands.shard/permeable/packages_test.dart
+1
-0
throwing_pub.dart
packages/flutter_tools/test/src/throwing_pub.dart
+7
-1
No files found.
packages/flutter_tools/lib/src/commands/packages.dart
View file @
bf89943d
...
...
@@ -20,7 +20,10 @@ import '../runner/flutter_command.dart';
class
PackagesCommand
extends
FlutterCommand
{
PackagesCommand
()
{
addSubcommand
(
PackagesGetCommand
(
'get'
,
false
));
addSubcommand
(
PackagesGetCommand
(
'upgrade'
,
true
));
//addSubcommand(PackagesGetCommand('upgrade', true));
addSubcommand
(
PackagesInteractiveGetCommand
(
'upgrade'
,
'Upgrade the current package
\'
s dependencies to latest versions.'
));
addSubcommand
(
PackagesInteractiveGetCommand
(
'add'
,
'Add a dependency to pubspec.yaml.'
));
addSubcommand
(
PackagesInteractiveGetCommand
(
'remove'
,
'Removes a dependency from the current package.'
));
addSubcommand
(
PackagesTestCommand
());
addSubcommand
(
PackagesForwardCommand
(
'publish'
,
'Publish the current package to pub.dartlang.org'
,
requiresPubspec:
true
));
addSubcommand
(
PackagesForwardCommand
(
'downgrade'
,
'Downgrade packages in a Flutter project'
,
requiresPubspec:
true
));
...
...
@@ -29,6 +32,8 @@ class PackagesCommand extends FlutterCommand {
addSubcommand
(
PackagesForwardCommand
(
'cache'
,
'Work with the Pub system cache'
));
addSubcommand
(
PackagesForwardCommand
(
'version'
,
'Print Pub version'
));
addSubcommand
(
PackagesForwardCommand
(
'uploader'
,
'Manage uploaders for a package on pub.dev'
));
addSubcommand
(
PackagesForwardCommand
(
'login'
,
'Log into pub.dev.'
));
addSubcommand
(
PackagesForwardCommand
(
'logout'
,
'Log out of pub.dev.'
));
addSubcommand
(
PackagesForwardCommand
(
'global'
,
'Work with Pub global packages'
));
addSubcommand
(
PackagesForwardCommand
(
'outdated'
,
'Analyze dependencies to find which ones can be upgraded'
,
requiresPubspec:
true
));
addSubcommand
(
PackagesPassthroughCommand
());
...
...
@@ -253,3 +258,82 @@ class PackagesPassthroughCommand extends FlutterCommand {
return
FlutterCommandResult
.
success
();
}
}
class
PackagesInteractiveGetCommand
extends
FlutterCommand
{
PackagesInteractiveGetCommand
(
this
.
_commandName
,
this
.
_description
)
{
requiresPubspecYaml
();
}
@override
ArgParser
argParser
=
ArgParser
.
allowAnything
();
final
String
_commandName
;
final
String
_description
;
@override
String
get
name
=>
_commandName
;
@override
String
get
description
{
return
'
$_description
.
\n
'
'This runs the "pub" tool in a Flutter context.'
;
}
@override
String
get
invocation
{
return
'
${runner.executableName}
pub
$_commandName
[<arguments...>]'
;
}
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
List
<
String
>
rest
=
argResults
.
rest
;
String
target
;
if
(
rest
.
length
==
1
&&
(
rest
[
0
].
contains
(
'/'
)
||
rest
[
0
].
contains
(
r'\'
)))
{
// HACK: Supporting flutter specific behavior where you can pass a
// folder to the command.
target
=
findProjectRoot
(
rest
[
0
]);
rest
=
<
String
>[];
}
else
{
target
=
findProjectRoot
();
}
if
(
target
==
null
)
{
throwToolExit
(
'Expected to find project root in '
'current working directory.'
);
}
final
FlutterProject
flutterProject
=
FlutterProject
.
fromPath
(
target
);
if
(
flutterProject
.
manifest
.
generateSyntheticPackage
)
{
final
Environment
environment
=
Environment
(
artifacts:
globals
.
artifacts
,
logger:
globals
.
logger
,
cacheDir:
globals
.
cache
.
getRoot
(),
engineVersion:
globals
.
flutterVersion
.
engineRevision
,
fileSystem:
globals
.
fs
,
flutterRootDir:
globals
.
fs
.
directory
(
Cache
.
flutterRoot
),
outputDir:
globals
.
fs
.
directory
(
getBuildDirectory
()),
processManager:
globals
.
processManager
,
projectDir:
flutterProject
.
directory
,
);
await
generateLocalizationsSyntheticPackage
(
environment:
environment
,
buildSystem:
globals
.
buildSystem
,
);
}
final
List
<
String
>
subArgs
=
rest
.
toList
()
..
removeWhere
((
String
arg
)
=>
arg
==
'--'
);
await
pub
.
interactively
(
<
String
>[
name
,
...
subArgs
],
directory:
target
,
stdio:
globals
.
stdio
,
touchesPackageConfig:
true
,
generateSyntheticPackage:
flutterProject
.
manifest
.
generateSyntheticPackage
,
);
await
flutterProject
.
regeneratePlatformSpecificTooling
();
return
FlutterCommandResult
.
success
();
}
}
packages/flutter_tools/lib/src/dart/pub.dart
View file @
bf89943d
...
...
@@ -127,6 +127,8 @@ abstract class Pub {
List
<
String
>
arguments
,
{
String
directory
,
@required
io
.
Stdio
stdio
,
bool
touchesPackageConfig
=
false
,
bool
generateSyntheticPackage
=
false
,
});
}
...
...
@@ -324,6 +326,8 @@ class _DefaultPub implements Pub {
List
<
String
>
arguments
,
{
String
directory
,
@required
io
.
Stdio
stdio
,
bool
touchesPackageConfig
=
false
,
bool
generateSyntheticPackage
=
false
,
})
async
{
final
io
.
Process
process
=
await
_processUtils
.
start
(
_pubCommand
(
arguments
),
...
...
@@ -357,6 +361,23 @@ class _DefaultPub implements Pub {
if
(
code
!=
0
)
{
throwToolExit
(
'pub finished with exit code
$code
'
,
exitCode:
code
);
}
if
(
touchesPackageConfig
)
{
final
File
packageConfigFile
=
_fileSystem
.
file
(
_fileSystem
.
path
.
join
(
directory
,
'.dart_tool'
,
'package_config.json'
));
final
Directory
generatedDirectory
=
_fileSystem
.
directory
(
_fileSystem
.
path
.
join
(
directory
,
'.dart_tool'
,
'flutter_gen'
));
final
File
lastVersion
=
_fileSystem
.
file
(
_fileSystem
.
path
.
join
(
directory
,
'.dart_tool'
,
'version'
));
final
File
currentVersion
=
_fileSystem
.
file
(
_fileSystem
.
path
.
join
(
Cache
.
flutterRoot
,
'version'
));
lastVersion
.
writeAsStringSync
(
currentVersion
.
readAsStringSync
());
await
_updatePackageConfig
(
packageConfigFile
,
generatedDirectory
,
generateSyntheticPackage
,
);
}
}
/// The command used for running pub.
...
...
packages/flutter_tools/test/commands.shard/permeable/packages_test.dart
View file @
bf89943d
...
...
@@ -374,6 +374,7 @@ void main() {
expectDependenciesResolved
(
projectPath
);
expectZeroPluginsInjected
(
projectPath
);
},
overrides:
<
Type
,
Generator
>{
Stdio:
()
=>
MockStdio
()..
stdout
.
terminalColumns
=
80
,
Pub:
()
=>
Pub
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
...
...
packages/flutter_tools/test/src/throwing_pub.dart
View file @
bf89943d
...
...
@@ -36,7 +36,13 @@ class ThrowingPub implements Pub {
}
@override
Future
<
void
>
interactively
(
List
<
String
>
arguments
,
{
String
directory
,
@required
Stdio
stdio
,})
{
Future
<
void
>
interactively
(
List
<
String
>
arguments
,
{
String
directory
,
@required
Stdio
stdio
,
bool
touchesPackageConfig
=
false
,
bool
generateSyntheticPackage
=
false
,
})
{
throw
UnsupportedError
(
'Attempted to invoke pub during test.'
);
}
}
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