Skip to content

Commit 9a8da3c

Browse files
authored
Flag pub publish --skip-validation to publish without resolution and validation (#3904)
1 parent d2798f9 commit 9a8da3c

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

lib/src/command/lish.dart

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class LishCommand extends PubCommand {
6666
/// Whether the publish requires confirmation.
6767
bool get force => argResults['force'];
6868

69+
bool get skipValidation => argResults['skip-validation'];
70+
6971
LishCommand() {
7072
argParser.addFlag(
7173
'dry-run',
@@ -79,6 +81,12 @@ class LishCommand extends PubCommand {
7981
negatable: false,
8082
help: 'Publish without confirmation if there are no errors.',
8183
);
84+
argParser.addFlag(
85+
'skip-validation',
86+
negatable: false,
87+
help:
88+
'Publish without validation and resolution (this will ignore errors).',
89+
);
8290
argParser.addOption(
8391
'server',
8492
help: 'The package server to which to upload this package.',
@@ -251,7 +259,13 @@ the \$PUB_HOSTED_URL environment variable.''',
251259
'pubspec.');
252260
}
253261

254-
await entrypoint.acquireDependencies(SolveType.get, analytics: analytics);
262+
if (!skipValidation) {
263+
await entrypoint.acquireDependencies(SolveType.get, analytics: analytics);
264+
} else {
265+
log.warning(
266+
'Running with `skip-validation`. No client-side validation is done.',
267+
);
268+
}
255269

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

269283
// Validate the package.
270-
var isValid = await _validate(
271-
packageBytesFuture.then((bytes) => bytes.length),
272-
files,
273-
);
284+
var isValid = skipValidation
285+
? true
286+
: await _validate(
287+
packageBytesFuture.then((bytes) => bytes.length),
288+
files,
289+
);
274290
if (!isValid) {
275291
overrideExitCode(exit_codes.DATA);
276292
return;

test/testdata/goldens/help_test/pub publish --help.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Usage: pub publish [options]
88
-h, --help Print this usage information.
99
-n, --dry-run Validate but do not publish the package.
1010
-f, --force Publish without confirmation if there are no errors.
11+
--skip-validation Publish without validation and resolution (this will ignore errors).
1112
-C, --directory=<dir> Run this in the directory <dir>.
1213

1314
Run "pub help" to see global options.

0 commit comments

Comments
 (0)