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
811f1ad9
Unverified
Commit
811f1ad9
authored
Apr 09, 2019
by
Michael Thomsen
Committed by
GitHub
Apr 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Forward missing pub commands (#30115)
parent
3fe81026
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
120 additions
and
1 deletion
+120
-1
packages.dart
packages/flutter_tools/lib/src/commands/packages.dart
+39
-0
pub.dart
packages/flutter_tools/lib/src/dart/pub.dart
+1
-0
packages_test.dart
packages/flutter_tools/test/commands/packages_test.dart
+80
-1
No files found.
packages/flutter_tools/lib/src/commands/packages.dart
View file @
811f1ad9
...
...
@@ -15,6 +15,14 @@ class PackagesCommand extends FlutterCommand {
addSubcommand
(
PackagesGetCommand
(
'get'
,
false
));
addSubcommand
(
PackagesGetCommand
(
'upgrade'
,
true
));
addSubcommand
(
PackagesTestCommand
());
addSubcommand
(
PackagesForwardCommand
(
'downgrade'
,
'Downgrade packages in a Flutter project'
,
requiresPubspec:
true
));
addSubcommand
(
PackagesForwardCommand
(
'publish'
,
'Publish the current package to pub.dartlang.org'
,
requiresPubspec:
true
));
addSubcommand
(
PackagesForwardCommand
(
'deps'
,
'Print package dependencies'
,
requiresPubspec:
true
));
addSubcommand
(
PackagesForwardCommand
(
'run'
,
'Run an executable from a package'
,
requiresPubspec:
true
));
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.dartlang.org'
));
addSubcommand
(
PackagesForwardCommand
(
'global'
,
'Work with Pub global packages'
));
addSubcommand
(
PackagesPassthroughCommand
());
}
...
...
@@ -129,6 +137,37 @@ class PackagesTestCommand extends FlutterCommand {
}
}
class
PackagesForwardCommand
extends
FlutterCommand
{
PackagesForwardCommand
(
this
.
_commandName
,
this
.
_description
,
{
bool
requiresPubspec
=
false
})
{
if
(
requiresPubspec
)
{
requiresPubspecYaml
();
}
}
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}
packages
$_commandName
[<arguments...>]'
;
}
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
await
pub
(<
String
>[
_commandName
]..
addAll
(
argResults
.
rest
),
context:
PubContext
.
pubForward
,
retry:
false
);
return
null
;
}
}
class
PackagesPassthroughCommand
extends
FlutterCommand
{
PackagesPassthroughCommand
()
{
requiresPubspecYaml
();
...
...
packages/flutter_tools/lib/src/dart/pub.dart
View file @
811f1ad9
...
...
@@ -41,6 +41,7 @@ class PubContext {
static
final
PubContext
interactive
=
PubContext
.
_
(<
String
>[
'interactive'
]);
static
final
PubContext
pubGet
=
PubContext
.
_
(<
String
>[
'get'
]);
static
final
PubContext
pubUpgrade
=
PubContext
.
_
(<
String
>[
'upgrade'
]);
static
final
PubContext
pubForward
=
PubContext
.
_
(<
String
>[
'forward'
]);
static
final
PubContext
runTest
=
PubContext
.
_
(<
String
>[
'run_test'
]);
static
final
PubContext
flutterTests
=
PubContext
.
_
(<
String
>[
'flutter_tests'
]);
...
...
packages/flutter_tools/test/commands/packages_test.dart
View file @
811f1ad9
...
...
@@ -308,7 +308,7 @@ void main() {
Stdio:
()
=>
mockStdio
,
});
testUsingContext
(
'publish'
,
()
async
{
testUsingContext
(
'pub
pub
lish'
,
()
async
{
final
PromptingProcess
process
=
PromptingProcess
();
mockProcessManager
.
processFactory
=
(
List
<
String
>
commands
)
=>
process
;
final
Future
<
void
>
runPackages
=
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'pub'
,
'publish'
]);
...
...
@@ -331,5 +331,84 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
});
testUsingContext
(
'publish'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'publish'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
3
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'--trace'
);
expect
(
commands
[
2
],
'publish'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysTrueBotDetector
(),
});
testUsingContext
(
'deps'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'deps'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
3
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'--trace'
);
expect
(
commands
[
2
],
'deps'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysTrueBotDetector
(),
});
testUsingContext
(
'cache'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'cache'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
3
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'--trace'
);
expect
(
commands
[
2
],
'cache'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysTrueBotDetector
(),
});
testUsingContext
(
'version'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'version'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
3
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'--trace'
);
expect
(
commands
[
2
],
'version'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysTrueBotDetector
(),
});
testUsingContext
(
'uploader'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'uploader'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
3
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'--trace'
);
expect
(
commands
[
2
],
'uploader'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysTrueBotDetector
(),
});
testUsingContext
(
'global'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'global'
,
'list'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
4
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'--trace'
);
expect
(
commands
[
2
],
'global'
);
expect
(
commands
[
3
],
'list'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysTrueBotDetector
(),
});
});
}
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