Skip to content

Commit 5553c59

Browse files
committed
Improve dry mode
1 parent aeaf0a3 commit 5553c59

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

packages/aft/lib/src/commands/publish_command.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ class PublishCommand extends AmplifyCommand with GlobOptions, PublishHelpers {
286286
await publish(package);
287287
},
288288
command: this,
289+
dryRun: dryRun,
289290
);
290291
await scheduler.run();
291292

packages/aft/lib/src/publish_scheduler.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ class PublishScheduler {
3434
required List<PackageInfo> packages,
3535
required PublishPackageFn publishPackage,
3636
required AmplifyCommand command,
37+
this.dryRun = false,
3738
}) : _packages = packages,
3839
_publishPackage = publishPackage,
3940
_command = command;
4041

4142
final List<PackageInfo> _packages;
4243
final PublishPackageFn _publishPackage;
4344
final AmplifyCommand _command;
45+
final bool dryRun;
4446

4547
/// Packages that are ready to be published (all in-process deps done).
4648
final List<PackageInfo> _packagePublishQueue = [];
@@ -212,6 +214,26 @@ class PublishScheduler {
212214
/// Publishes all packages, processing the queue without blocking on
213215
/// analysis.
214216
Future<void> run() async {
217+
if (dryRun) {
218+
return _runDryRun();
219+
}
220+
return _runNormal();
221+
}
222+
223+
/// Dry-run mode: simply iterate through the packages in the provided
224+
/// order and call [_publishPackage] for each one.
225+
Future<void> _runDryRun() async {
226+
for (final package in _packages) {
227+
stdout.writeln('Publishing ${package.name} (${package.version}) [dry run]');
228+
await _publishPackage(package);
229+
stdout.writeln('');
230+
}
231+
stdout.writeln('All packages passed pre-publish checks (dry run).');
232+
}
233+
234+
/// Normal (non-dry-run) publish flow that processes the queue without
235+
/// blocking on analysis.
236+
Future<void> _runNormal() async {
215237
final adjacencyLists = _buildAdjacencyLists();
216238

217239
/// Tracks which packages have been published (publish call returned).

0 commit comments

Comments
 (0)