|
14 | 14 |
|
15 | 15 | import {GitHub} from '../github';
|
16 | 16 | import {CandidateReleasePullRequest, RepositoryConfig} from '../manifest';
|
| 17 | +import {PackageLockJson} from '../updaters/node/package-lock-json'; |
17 | 18 | import {Version, VersionsMap} from '../version';
|
18 | 19 | import {PullRequestTitle} from '../util/pull-request-title';
|
19 | 20 | import {PullRequestBody} from '../util/pull-request-body';
|
@@ -82,6 +83,7 @@ export class NodeWorkspace extends WorkspacePlugin<Package> {
|
82 | 83 | options: NodeWorkspaceOptions = {}
|
83 | 84 | ) {
|
84 | 85 | super(github, targetBranch, repositoryConfig, options);
|
| 86 | + |
85 | 87 | this.alwaysLinkLocal = options.alwaysLinkLocal === false ? false : true;
|
86 | 88 | this.updatePeerDependencies = options.updatePeerDependencies === true;
|
87 | 89 | }
|
@@ -201,6 +203,13 @@ export class NodeWorkspace extends WorkspacePlugin<Package> {
|
201 | 203 | existingCandidate.pullRequest.updates.map(update => {
|
202 | 204 | if (update.path === addPath(existingCandidate.path, 'package.json')) {
|
203 | 205 | update.updater = new CompositeUpdater(update.updater, updater);
|
| 206 | + } else if ( |
| 207 | + update.path === addPath(existingCandidate.path, 'package-lock.json') |
| 208 | + ) { |
| 209 | + update.updater = new PackageLockJson({ |
| 210 | + version: newVersion, |
| 211 | + versionsMap: updatedVersions, |
| 212 | + }); |
204 | 213 | } else if (update.updater instanceof Changelog) {
|
205 | 214 | if (dependencyNotes) {
|
206 | 215 | update.updater.changelogEntry =
|
@@ -303,6 +312,14 @@ export class NodeWorkspace extends WorkspacePlugin<Package> {
|
303 | 312 | versionsMap: updatedVersions,
|
304 | 313 | }),
|
305 | 314 | },
|
| 315 | + { |
| 316 | + path: addPath(updatedPackage.path, 'package-lock.json'), |
| 317 | + createIfMissing: false, |
| 318 | + updater: new PackageJson({ |
| 319 | + version: newVersion, |
| 320 | + versionsMap: updatedVersions, |
| 321 | + }), |
| 322 | + }, |
306 | 323 | {
|
307 | 324 | path: addPath(updatedPackage.path, 'CHANGELOG.md'),
|
308 | 325 | createIfMissing: false,
|
@@ -334,7 +351,39 @@ export class NodeWorkspace extends WorkspacePlugin<Package> {
|
334 | 351 | candidates: CandidateReleasePullRequest[],
|
335 | 352 | _updatedVersions: VersionsMap
|
336 | 353 | ): CandidateReleasePullRequest[] {
|
337 |
| - // NOP for node workspaces |
| 354 | + if (candidates.length === 0) { |
| 355 | + return candidates; |
| 356 | + } |
| 357 | + |
| 358 | + const [candidate] = candidates; |
| 359 | + |
| 360 | + // check for root lock file in pull request |
| 361 | + let hasRootLockFile: boolean | undefined; |
| 362 | + for (let i = 0; i < candidate.pullRequest.updates.length; i++) { |
| 363 | + if ( |
| 364 | + candidate.pullRequest.updates[i].path === '.package-lock.json' || |
| 365 | + candidate.pullRequest.updates[i].path === './package-lock.json' || |
| 366 | + candidate.pullRequest.updates[i].path === 'package-lock.json' || |
| 367 | + candidate.pullRequest.updates[i].path === '/package-lock.json' |
| 368 | + ) { |
| 369 | + hasRootLockFile = true; |
| 370 | + break; |
| 371 | + } |
| 372 | + } |
| 373 | + |
| 374 | + // if there is a root lock file, then there is no additional pull request update necessary. |
| 375 | + if (hasRootLockFile) { |
| 376 | + return candidates; |
| 377 | + } |
| 378 | + |
| 379 | + candidate.pullRequest.updates.push({ |
| 380 | + path: 'package-lock.json', |
| 381 | + createIfMissing: false, |
| 382 | + updater: new PackageLockJson({ |
| 383 | + versionsMap: _updatedVersions, |
| 384 | + }), |
| 385 | + }); |
| 386 | + |
338 | 387 | return candidates;
|
339 | 388 | }
|
340 | 389 |
|
|
0 commit comments