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
79d89675
Unverified
Commit
79d89675
authored
Aug 19, 2019
by
Michael Thomsen
Committed by
GitHub
Aug 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix publish cmd (#38490)
parent
024a1d26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
6 deletions
+58
-6
packages.dart
packages/flutter_tools/lib/src/commands/packages.dart
+42
-1
packages_test.dart
...tter_tools/test/general.shard/commands/packages_test.dart
+16
-5
No files found.
packages/flutter_tools/lib/src/commands/packages.dart
View file @
79d89675
...
...
@@ -17,8 +17,8 @@ class PackagesCommand extends FlutterCommand {
addSubcommand
(
PackagesGetCommand
(
'get'
,
false
));
addSubcommand
(
PackagesGetCommand
(
'upgrade'
,
true
));
addSubcommand
(
PackagesTestCommand
());
addSubcommand
(
PackagesPublishCommand
());
addSubcommand
(
PackagesForwardCommand
(
'downgrade'
,
'Downgrade packages in a Flutter project'
,
requiresPubspec:
true
));
addSubcommand
(
PackagesForwardCommand
(
'publish'
,
'Publish the current package to pub.dev'
,
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'
));
...
...
@@ -170,6 +170,47 @@ class PackagesTestCommand extends FlutterCommand {
}
}
class
PackagesPublishCommand
extends
FlutterCommand
{
PackagesPublishCommand
()
{
requiresPubspecYaml
();
argParser
.
addFlag
(
'dry-run'
,
abbr:
'n'
,
negatable:
false
,
help:
'Validate but do not publish the package.'
,
);
argParser
.
addFlag
(
'force'
,
abbr:
'f'
,
negatable:
false
,
help:
'Publish without confirmation if there are no errors.'
,
);
}
@override
String
get
name
=>
'publish'
;
@override
String
get
description
{
return
'Publish the current package to pub.dev'
;
}
@override
String
get
invocation
{
return
'
${runner.executableName}
pub publish [--dry-run]'
;
}
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
final
List
<
String
>
args
=
<
String
>[
...
argResults
.
rest
,
if
(
argResults
[
'dry-run'
])
'--dry-run'
,
if
(
argResults
[
'force'
])
'--force'
,
];
Cache
.
releaseLockEarly
();
await
pubInteractively
(<
String
>[
'publish'
,
...
args
]);
return
null
;
}
}
class
PackagesForwardCommand
extends
FlutterCommand
{
PackagesForwardCommand
(
this
.
_commandName
,
this
.
_description
,
{
bool
requiresPubspec
=
false
})
{
if
(
requiresPubspec
)
{
...
...
packages/flutter_tools/test/general.shard/commands/packages_test.dart
View file @
79d89675
...
...
@@ -348,7 +348,7 @@ void main() {
testUsingContext
(
'pub publish'
,
()
async
{
final
PromptingProcess
process
=
PromptingProcess
();
mockProcessManager
.
processFactory
=
(
List
<
String
>
commands
)
=>
process
;
final
Future
<
void
>
runPackages
=
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'p
ackages'
,
'p
ub'
,
'publish'
]);
final
Future
<
void
>
runPackages
=
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'pub'
,
'publish'
]);
final
Future
<
void
>
runPrompt
=
process
.
showPrompt
(
'Proceed (y/n)? '
,
<
String
>[
'hello'
,
'world'
]);
final
Future
<
void
>
simulateUserInput
=
Future
<
void
>(()
{
mockStdio
.
simulateStdin
(
'y'
);
...
...
@@ -370,12 +370,23 @@ void main() {
});
testUsingContext
(
'publish'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'p
ackages
'
,
'publish'
]);
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'p
ub
'
,
'publish'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
3
));
expect
(
commands
,
hasLength
(
2
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'--trace'
);
expect
(
commands
[
2
],
'publish'
);
expect
(
commands
[
1
],
'publish'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysTrueBotDetector
(),
});
testUsingContext
(
'packages publish'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'pub'
,
'publish'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
2
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'publish'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
...
...
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