Skip to content

Commit 20a8168

Browse files
committed
feat(@schematics/update): add doc for --force flag
And show packages that have invalid deps when --force, but as a warning.
1 parent 5d5be75 commit 20a8168

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

docs/specifications/update.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ You can specify more than one package. Each package follows the convention of `[
1616
| Flag | Argument | Description |
1717
|---|---|---|
1818
| `--all` | `boolean` | If true, implies that all dependencies should be updated. Defaults is false, using dependencies from the command line instead. |
19+
| `--force` | `boolean` | If true, skip the verification step and perform the update even if some peer dependencies would be invalidated. Peer dependencies errors will still be shown as warning. Defaults to false. |
1920
| `--next` | `boolean` | If true, allows version discovery to include Beta and RC. Defaults to false. |
2021
| `--migration-only` | `boolean` | If true, don't change the `package.json` file, only apply migration scripts. |
2122
| `--from` | `version` | Apply migrations from a certain version number. |

packages/schematics/update/update/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ function _validateReversePeerDependencies(
113113

114114
function _validateUpdatePackages(
115115
infoMap: Map<string, PackageInfo>,
116+
force: boolean,
116117
logger: logging.LoggerApi,
117118
): void {
118-
logger = logger.createChild('validateUpdate');
119119
logger.debug('Updating the following packages:');
120120
infoMap.forEach(info => {
121121
if (info.target) {
@@ -140,7 +140,7 @@ function _validateUpdatePackages(
140140
|| peerErrors;
141141
});
142142

143-
if (peerErrors) {
143+
if (!force && peerErrors) {
144144
throw new SchematicsException(`Incompatible peer dependencies found. See above.`);
145145
}
146146
}
@@ -619,9 +619,12 @@ export default function(options: UpdateSchema): Rule {
619619
switchMap(infoMap => {
620620
// Now that we have all the information, check the flags.
621621
if (packages.size > 0) {
622-
if (!options.force) {
623-
_validateUpdatePackages(infoMap, logger);
624-
}
622+
const sublog = new logging.LevelCapLogger(
623+
'validation',
624+
logger.createChild(''),
625+
'warn',
626+
);
627+
_validateUpdatePackages(infoMap, options.force, sublog);
625628

626629
return _performUpdate(tree, context, infoMap, logger);
627630
} else {

0 commit comments

Comments
 (0)