@@ -10,19 +10,12 @@ import 'package:aft/src/changelog/printer.dart';
10
10
import 'package:aft/src/options/git_ref_options.dart' ;
11
11
import 'package:aft/src/options/glob_options.dart' ;
12
12
import 'package:aft/src/repo.dart' ;
13
- import 'package:path/path.dart' as p;
14
13
15
14
/// Command for bumping package versions across the repo.
16
15
class VersionBumpCommand extends AmplifyCommand
17
16
with GitRefOptions , GlobOptions {
18
17
VersionBumpCommand () {
19
18
argParser
20
- ..addFlag (
21
- 'preview' ,
22
- help: 'Preview version changes without applying' ,
23
- defaultsTo: false ,
24
- negatable: false ,
25
- )
26
19
..addFlag (
27
20
'yes' ,
28
21
abbr: 'y' ,
@@ -56,8 +49,6 @@ class VersionBumpCommand extends AmplifyCommand
56
49
57
50
late final bool yes = argResults! ['yes' ] as bool ;
58
51
59
- late final bool preview = argResults! ['preview' ] as bool ;
60
-
61
52
late final VersionBumpType ? forcedBumpType = () {
62
53
final forceBreaking = argResults! ['force-breaking' ] as bool ;
63
54
if (forceBreaking) return VersionBumpType .breaking;
@@ -85,40 +76,9 @@ class VersionBumpCommand extends AmplifyCommand
85
76
changesForPackage: _changesForPackage,
86
77
forcedBumpType: forcedBumpType,
87
78
);
88
- final changelogUpdates = repo.changelogUpdates;
89
-
90
- final bumpedPackages = < PackageInfo > [];
91
- for (final package in repo.publishablePackages ()) {
92
- final edits = package.pubspecInfo.pubspecYamlEditor.edits;
93
- if (edits.isEmpty) {
94
- continue ;
95
- }
96
- bumpedPackages.add (package);
97
- if (preview) {
98
- logger.info ('pubspec.yaml' );
99
- for (final edit in edits) {
100
- final originalText = package.pubspecInfo.pubspecYaml
101
- .substring (edit.offset, edit.offset + edit.length);
102
- logger.info ('$originalText --> ${edit .replacement }' );
103
- }
104
- } else {
105
- await File (p.join (package.path, 'pubspec.yaml' ))
106
- .writeAsString (package.pubspecInfo.pubspecYamlEditor.toString ());
107
- }
108
- final changelogUpdate = changelogUpdates[package];
109
- if (changelogUpdate != null && changelogUpdate.hasUpdate) {
110
- if (preview) {
111
- logger
112
- ..info ('CHANGELOG.md' )
113
- ..info (changelogUpdate.newText! );
114
- } else {
115
- await File (p.join (package.path, 'CHANGELOG.md' ))
116
- .writeAsString (changelogUpdate.toString ());
117
- }
118
- }
119
- }
120
-
121
- return bumpedPackages;
79
+ return repo.writeChanges (
80
+ packages: repo.publishablePackages (),
81
+ );
122
82
}
123
83
124
84
@override
@@ -130,20 +90,18 @@ class VersionBumpCommand extends AmplifyCommand
130
90
131
91
final bumpedPackages = await _updateVersions ();
132
92
133
- if (! preview) {
134
- for (final package in bumpedPackages) {
135
- // Run build_runner for packages which generate their version number.
136
- final needsBuildRunner = package.pubspecInfo.pubspec.devDependencies
137
- .containsKey ('build_version' );
138
- if (! needsBuildRunner) {
139
- continue ;
140
- }
141
- await runBuildRunner (
142
- package,
143
- logger: logger,
144
- verbose: verbose,
145
- );
93
+ for (final package in bumpedPackages) {
94
+ // Run build_runner for packages which generate their version number.
95
+ final needsBuildRunner = package.pubspecInfo.pubspec.devDependencies
96
+ .containsKey ('build_version' );
97
+ if (! needsBuildRunner) {
98
+ continue ;
146
99
}
100
+ await runBuildRunner (
101
+ package,
102
+ logger: logger,
103
+ verbose: verbose,
104
+ );
147
105
}
148
106
149
107
logger.info ('Version successfully bumped' );
0 commit comments