Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag pub publish --skip-validation to publish without resolution and validation #3904

Merged
merged 3 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions lib/src/command/lish.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ class LishCommand extends PubCommand {
negatable: false,
help: 'Publish without confirmation if there are no errors.',
);
argParser.addFlag(
'skip-validation',
negatable: false,
help:
'Publish without validation and resolution (this will ignore errors).',
);
argParser.addOption(
'server',
help: 'The package server to which to upload this package.',
Expand Down Expand Up @@ -251,7 +257,13 @@ the \$PUB_HOSTED_URL environment variable.''',
'pubspec.');
}

await entrypoint.acquireDependencies(SolveType.get, analytics: analytics);
if (!argResults['skip-validation']) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe do a getter for argResult['skip-validation']

await entrypoint.acquireDependencies(SolveType.get, analytics: analytics);
} else {
log.warning(
'Running with `skip-validation`. No client-side validation is done.',
);
}

var files = entrypoint.root.listFiles();
log.fine('Archiving and publishing ${entrypoint.root.name}.');
Expand All @@ -267,10 +279,12 @@ the \$PUB_HOSTED_URL environment variable.''',
createTarGz(files, baseDir: entrypoint.rootDir).toBytes();

// Validate the package.
var isValid = await _validate(
packageBytesFuture.then((bytes) => bytes.length),
files,
);
var isValid = argResults['skip-validation']
? true
: await _validate(
packageBytesFuture.then((bytes) => bytes.length),
files,
);
if (!isValid) {
overrideExitCode(exit_codes.DATA);
return;
Expand Down
1 change: 1 addition & 0 deletions test/testdata/goldens/help_test/pub publish --help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Usage: pub publish [options]
-h, --help Print this usage information.
-n, --dry-run Validate but do not publish the package.
-f, --force Publish without confirmation if there are no errors.
--skip-validation Publish without validation and resolution (this will ignore errors).
-C, --directory=<dir> Run this in the directory <dir>.

Run "pub help" to see global options.
Expand Down