release-please 16.5.1 → 16.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,4 +14,4 @@ export { Logger, setLogger } from './util/logger';
14
14
  export { GitHub } from './github';
15
15
  export declare const configSchema: any;
16
16
  export declare const manifestSchema: any;
17
- export declare const VERSION = "16.5.1";
17
+ export declare const VERSION = "16.7.0";
@@ -36,6 +36,6 @@ Object.defineProperty(exports, "GitHub", { enumerable: true, get: function () {
36
36
  exports.configSchema = require('../../schemas/config.json');
37
37
  exports.manifestSchema = require('../../schemas/manifest.json');
38
38
  // x-release-please-start-version
39
- exports.VERSION = '16.5.1';
39
+ exports.VERSION = '16.7.0';
40
40
  // x-release-please-end
41
41
  //# sourceMappingURL=index.js.map
@@ -42,7 +42,7 @@ export declare class CargoWorkspace extends WorkspacePlugin<CrateInfo> {
42
42
  }>;
43
43
  protected bumpVersion(pkg: CrateInfo): Version;
44
44
  protected updateCandidate(existingCandidate: CandidateReleasePullRequest, pkg: CrateInfo, updatedVersions: VersionsMap): CandidateReleasePullRequest;
45
- protected newCandidate(pkg: CrateInfo, updatedVersions: VersionsMap): CandidateReleasePullRequest;
45
+ protected newCandidate(pkg: CrateInfo, updatedVersions: VersionsMap): Promise<CandidateReleasePullRequest>;
46
46
  protected postProcessCandidates(candidates: CandidateReleasePullRequest[], updatedVersions: VersionsMap): CandidateReleasePullRequest[];
47
47
  protected buildGraph(allPackages: CrateInfo[]): Promise<DependencyGraph<CrateInfo>>;
48
48
  protected inScope(candidate: CandidateReleasePullRequest): boolean;
@@ -130,7 +130,7 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
130
130
  }
131
131
  return existingCandidate;
132
132
  }
133
- newCandidate(pkg, updatedVersions) {
133
+ async newCandidate(pkg, updatedVersions) {
134
134
  const version = updatedVersions.get(pkg.name);
135
135
  if (!version) {
136
136
  throw new Error(`Didn't find updated version for ${pkg.name}`);
@@ -72,7 +72,7 @@ export declare class MavenWorkspace extends WorkspacePlugin<MavenArtifact> {
72
72
  protected isReleaseVersion(version: Version): boolean;
73
73
  protected bumpVersion(artifact: MavenArtifact): Version;
74
74
  protected updateCandidate(existingCandidate: CandidateReleasePullRequest, artifact: MavenArtifact, updatedVersions: VersionsMap): CandidateReleasePullRequest;
75
- protected newCandidate(artifact: MavenArtifact, updatedVersions: VersionsMap): CandidateReleasePullRequest;
75
+ protected newCandidate(artifact: MavenArtifact, updatedVersions: VersionsMap): Promise<CandidateReleasePullRequest>;
76
76
  protected inScope(candidate: CandidateReleasePullRequest): boolean;
77
77
  protected packageNameFromPackage(artifact: MavenArtifact): string;
78
78
  protected pathFromPackage(artifact: MavenArtifact): string;
@@ -266,7 +266,7 @@ class MavenWorkspace extends workspace_1.WorkspacePlugin {
266
266
  }
267
267
  return existingCandidate;
268
268
  }
269
- newCandidate(artifact, updatedVersions) {
269
+ async newCandidate(artifact, updatedVersions) {
270
270
  const version = updatedVersions.get(artifact.name);
271
271
  if (!version) {
272
272
  throw new Error(`Didn't find updated version for ${artifact.name}`);
@@ -2,6 +2,9 @@ import { GitHub } from '../github';
2
2
  import { CandidateReleasePullRequest, RepositoryConfig } from '../manifest';
3
3
  import { Version, VersionsMap } from '../version';
4
4
  import { WorkspacePlugin, DependencyGraph, WorkspacePluginOptions } from './workspace';
5
+ import { Strategy } from '../strategy';
6
+ import { Commit } from '../commit';
7
+ import { Release } from '../release';
5
8
  interface Package {
6
9
  path: string;
7
10
  name: string;
@@ -25,6 +28,8 @@ interface NodeWorkspaceOptions extends WorkspacePluginOptions {
25
28
  */
26
29
  export declare class NodeWorkspace extends WorkspacePlugin<Package> {
27
30
  private alwaysLinkLocal;
31
+ private strategiesByPath;
32
+ private releasesByPath;
28
33
  readonly updatePeerDependencies: boolean;
29
34
  constructor(github: GitHub, targetBranch: string, repositoryConfig: RepositoryConfig, options?: NodeWorkspaceOptions);
30
35
  protected buildAllPackages(candidates: CandidateReleasePullRequest[]): Promise<{
@@ -33,12 +38,13 @@ export declare class NodeWorkspace extends WorkspacePlugin<Package> {
33
38
  }>;
34
39
  protected bumpVersion(pkg: Package): Version;
35
40
  protected updateCandidate(existingCandidate: CandidateReleasePullRequest, pkg: Package, updatedVersions: VersionsMap): CandidateReleasePullRequest;
36
- protected newCandidate(pkg: Package, updatedVersions: VersionsMap): CandidateReleasePullRequest;
41
+ protected newCandidate(pkg: Package, updatedVersions: VersionsMap): Promise<CandidateReleasePullRequest>;
37
42
  protected postProcessCandidates(candidates: CandidateReleasePullRequest[], _updatedVersions: VersionsMap): CandidateReleasePullRequest[];
38
43
  protected buildGraph(allPackages: Package[]): Promise<DependencyGraph<Package>>;
39
44
  protected inScope(candidate: CandidateReleasePullRequest): boolean;
40
45
  protected packageNameFromPackage(pkg: Package): string;
41
46
  protected pathFromPackage(pkg: Package): string;
42
47
  private combineDeps;
48
+ preconfigure(strategiesByPath: Record<string, Strategy>, _commitsByPath: Record<string, Commit[]>, _releasesByPath: Record<string, Release>): Promise<Record<string, Strategy>>;
43
49
  }
44
50
  export {};
@@ -14,6 +14,7 @@
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.NodeWorkspace = void 0;
17
+ const package_lock_json_1 = require("../updaters/node/package-lock-json");
17
18
  const version_1 = require("../version");
18
19
  const pull_request_title_1 = require("../util/pull-request-title");
19
20
  const pull_request_body_1 = require("../util/pull-request-body");
@@ -33,6 +34,8 @@ const package_json_1 = require("../updaters/node/package-json");
33
34
  class NodeWorkspace extends workspace_1.WorkspacePlugin {
34
35
  constructor(github, targetBranch, repositoryConfig, options = {}) {
35
36
  super(github, targetBranch, repositoryConfig, options);
37
+ this.strategiesByPath = {};
38
+ this.releasesByPath = {};
36
39
  this.alwaysLinkLocal = options.alwaysLinkLocal === false ? false : true;
37
40
  this.updatePeerDependencies = options.updatePeerDependencies === true;
38
41
  }
@@ -118,6 +121,12 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
118
121
  if (update.path === (0, workspace_1.addPath)(existingCandidate.path, 'package.json')) {
119
122
  update.updater = new composite_1.CompositeUpdater(update.updater, updater);
120
123
  }
124
+ else if (update.path === (0, workspace_1.addPath)(existingCandidate.path, 'package-lock.json')) {
125
+ update.updater = new package_lock_json_1.PackageLockJson({
126
+ version: newVersion,
127
+ versionsMap: updatedVersions,
128
+ });
129
+ }
121
130
  else if (update.updater instanceof changelog_1.Changelog) {
122
131
  if (dependencyNotes) {
123
132
  update.updater.changelogEntry =
@@ -142,7 +151,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
142
151
  }
143
152
  return existingCandidate;
144
153
  }
145
- newCandidate(pkg, updatedVersions) {
154
+ async newCandidate(pkg, updatedVersions) {
146
155
  // Update version of the package
147
156
  const newVersion = updatedVersions.get(pkg.name);
148
157
  if (!newVersion) {
@@ -153,6 +162,22 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
153
162
  version: newVersion.toString(),
154
163
  };
155
164
  const dependencyNotes = getChangelogDepsNotes(pkg, updatedPackage, updatedVersions, this.logger);
165
+ const strategy = this.strategiesByPath[updatedPackage.path];
166
+ const latestRelease = this.releasesByPath[updatedPackage.path];
167
+ const basePullRequest = strategy
168
+ ? await strategy.buildReleasePullRequest([], latestRelease, false, [], {
169
+ newVersion,
170
+ })
171
+ : undefined;
172
+ if (basePullRequest) {
173
+ return this.updateCandidate({
174
+ path: pkg.path,
175
+ pullRequest: basePullRequest,
176
+ config: {
177
+ releaseType: 'node',
178
+ },
179
+ }, pkg, updatedVersions);
180
+ }
156
181
  const pullRequest = {
157
182
  title: pull_request_title_1.PullRequestTitle.ofTargetBranch(this.targetBranch),
158
183
  body: new pull_request_body_1.PullRequestBody([
@@ -171,6 +196,14 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
171
196
  versionsMap: updatedVersions,
172
197
  }),
173
198
  },
199
+ {
200
+ path: (0, workspace_1.addPath)(updatedPackage.path, 'package-lock.json'),
201
+ createIfMissing: false,
202
+ updater: new package_json_1.PackageJson({
203
+ version: newVersion,
204
+ versionsMap: updatedVersions,
205
+ }),
206
+ },
174
207
  {
175
208
  path: (0, workspace_1.addPath)(updatedPackage.path, 'CHANGELOG.md'),
176
209
  createIfMissing: false,
@@ -194,7 +227,32 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
194
227
  };
195
228
  }
196
229
  postProcessCandidates(candidates, _updatedVersions) {
197
- // NOP for node workspaces
230
+ if (candidates.length === 0) {
231
+ return candidates;
232
+ }
233
+ const [candidate] = candidates;
234
+ // check for root lock file in pull request
235
+ let hasRootLockFile;
236
+ for (let i = 0; i < candidate.pullRequest.updates.length; i++) {
237
+ if (candidate.pullRequest.updates[i].path === '.package-lock.json' ||
238
+ candidate.pullRequest.updates[i].path === './package-lock.json' ||
239
+ candidate.pullRequest.updates[i].path === 'package-lock.json' ||
240
+ candidate.pullRequest.updates[i].path === '/package-lock.json') {
241
+ hasRootLockFile = true;
242
+ break;
243
+ }
244
+ }
245
+ // if there is a root lock file, then there is no additional pull request update necessary.
246
+ if (hasRootLockFile) {
247
+ return candidates;
248
+ }
249
+ candidate.pullRequest.updates.push({
250
+ path: 'package-lock.json',
251
+ createIfMissing: false,
252
+ updater: new package_lock_json_1.PackageLockJson({
253
+ versionsMap: _updatedVersions,
254
+ }),
255
+ });
198
256
  return candidates;
199
257
  }
200
258
  async buildGraph(allPackages) {
@@ -230,6 +288,12 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
230
288
  : {}),
231
289
  };
232
290
  }
291
+ async preconfigure(strategiesByPath, _commitsByPath, _releasesByPath) {
292
+ // Using preconfigure to siphon releases and strategies.
293
+ this.strategiesByPath = strategiesByPath;
294
+ this.releasesByPath = _releasesByPath;
295
+ return strategiesByPath;
296
+ }
233
297
  }
234
298
  exports.NodeWorkspace = NodeWorkspace;
235
299
  function getChangelogDepsNotes(original, updated, updateVersions, logger) {
@@ -105,7 +105,7 @@ export declare abstract class WorkspacePlugin<T> extends ManifestPlugin {
105
105
  * update.
106
106
  * @returns {CandidateReleasePullRequest} A new pull request
107
107
  */
108
- protected abstract newCandidate(pkg: T, updatedVersions: VersionsMap): CandidateReleasePullRequest;
108
+ protected abstract newCandidate(pkg: T, updatedVersions: VersionsMap): Promise<CandidateReleasePullRequest>;
109
109
  /**
110
110
  * Collect all packages being managed in this workspace.
111
111
  * @param {CanididateReleasePullRequest[]} candidates Existing candidate pull
@@ -86,7 +86,7 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin {
86
86
  else {
87
87
  // otherwise, build a new pull request with changelog and entry update
88
88
  this.logger.info(`Creating new candidate pull request for ${this.packageNameFromPackage(pkg)}`);
89
- const newCandidate = this.newCandidate(pkg, updatedVersions);
89
+ const newCandidate = await this.newCandidate(pkg, updatedVersions);
90
90
  if (newCandidatePaths.has(newCandidate.path)) {
91
91
  this.logger.info(`Already created new candidate for path: ${newCandidate.path}`);
92
92
  }
@@ -1,4 +1,4 @@
1
- import { Strategy, BuildReleaseOptions } from '../strategy';
1
+ import { Strategy, BuildReleaseOptions, BumpReleaseOptions } from '../strategy';
2
2
  import { GitHub } from '../github';
3
3
  import { VersioningStrategy } from '../versioning-strategy';
4
4
  import { Repository } from '../repository';
@@ -115,7 +115,7 @@ export declare abstract class BaseStrategy implements Strategy {
115
115
  * open for this path/component. Returns undefined if we should not
116
116
  * open a pull request.
117
117
  */
118
- buildReleasePullRequest(commits: ConventionalCommit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
118
+ buildReleasePullRequest(commits: ConventionalCommit[], latestRelease?: Release, draft?: boolean, labels?: string[], bumpOnlyOptions?: BumpReleaseOptions): Promise<ReleasePullRequest | undefined>;
119
119
  private extraFilePaths;
120
120
  protected extraFileUpdates(version: Version, versionsMap: VersionsMap): Promise<Update[]>;
121
121
  protected changelogEmpty(changelogEntry: string): boolean;
@@ -142,14 +142,15 @@ class BaseStrategy {
142
142
  * open for this path/component. Returns undefined if we should not
143
143
  * open a pull request.
144
144
  */
145
- async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
145
+ async buildReleasePullRequest(commits, latestRelease, draft, labels = [], bumpOnlyOptions) {
146
+ var _a;
146
147
  const conventionalCommits = await this.postProcessCommits(commits);
147
148
  this.logger.info(`Considering: ${conventionalCommits.length} commits`);
148
- if (conventionalCommits.length === 0) {
149
+ if (!bumpOnlyOptions && conventionalCommits.length === 0) {
149
150
  this.logger.info(`No commits for path: ${this.path}, skipping`);
150
151
  return undefined;
151
152
  }
152
- const newVersion = await this.buildNewVersion(conventionalCommits, latestRelease);
153
+ const newVersion = (_a = bumpOnlyOptions === null || bumpOnlyOptions === void 0 ? void 0 : bumpOnlyOptions.newVersion) !== null && _a !== void 0 ? _a : (await this.buildNewVersion(conventionalCommits, latestRelease));
153
154
  const versionsMap = await this.updateVersionsMap(await this.buildVersionsMap(conventionalCommits), conventionalCommits, newVersion);
154
155
  const component = await this.getComponent();
155
156
  this.logger.debug('component:', component);
@@ -161,7 +162,7 @@ class BaseStrategy {
161
162
  ? branch_name_1.BranchName.ofComponentTargetBranch(branchComponent, this.targetBranch)
162
163
  : branch_name_1.BranchName.ofTargetBranch(this.targetBranch);
163
164
  const releaseNotesBody = await this.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease, commits);
164
- if (this.changelogEmpty(releaseNotesBody)) {
165
+ if (!bumpOnlyOptions && this.changelogEmpty(releaseNotesBody)) {
165
166
  this.logger.info(`No user facing commits found since ${latestRelease ? latestRelease.sha : 'beginning of time'} - skipping`);
166
167
  return undefined;
167
168
  }
@@ -5,6 +5,7 @@ import { ConventionalCommit } from '../commit';
5
5
  import { Release } from '../release';
6
6
  import { ReleasePullRequest } from '../release-pull-request';
7
7
  import { VersioningStrategy } from '../versioning-strategy';
8
+ import { BumpReleaseOptions } from '../strategy';
8
9
  export interface JavaBuildUpdatesOption extends BuildUpdatesOptions {
9
10
  isSnapshot?: boolean;
10
11
  }
@@ -18,7 +19,7 @@ export declare class Java extends BaseStrategy {
18
19
  protected readonly snapshotLabels: string[];
19
20
  readonly skipSnapshot: boolean;
20
21
  constructor(options: BaseStrategyOptions);
21
- buildReleasePullRequest(commits: ConventionalCommit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
22
+ buildReleasePullRequest(commits: ConventionalCommit[], latestRelease?: Release, draft?: boolean, labels?: string[], _bumpOnlyOptions?: BumpReleaseOptions): Promise<ReleasePullRequest | undefined>;
22
23
  protected buildSnapshotPullRequest(latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest>;
23
24
  isPublishedVersion(version: Version): boolean;
24
25
  protected needsSnapshot(commits: ConventionalCommit[], latestRelease?: Release): Promise<boolean>;
@@ -58,7 +58,7 @@ class Java extends base_1.BaseStrategy {
58
58
  this.snapshotLabels = options.snapshotLabels || manifest_1.DEFAULT_SNAPSHOT_LABELS;
59
59
  this.skipSnapshot = (_c = options.skipSnapshot) !== null && _c !== void 0 ? _c : false;
60
60
  }
61
- async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
61
+ async buildReleasePullRequest(commits, latestRelease, draft, labels = [], _bumpOnlyOptions) {
62
62
  if (await this.needsSnapshot(commits, latestRelease)) {
63
63
  this.logger.info('Repository needs a snapshot bump.');
64
64
  return await this.buildSnapshotPullRequest(latestRelease, draft, this.snapshotLabels);
@@ -27,6 +27,7 @@ class Node extends base_1.BaseStrategy {
27
27
  var _a;
28
28
  const updates = [];
29
29
  const version = options.newVersion;
30
+ const versionsMap = options.versionsMap;
30
31
  const packageName = (_a = (await this.getPackageName())) !== null && _a !== void 0 ? _a : '';
31
32
  const lockFiles = ['package-lock.json', 'npm-shrinkwrap.json'];
32
33
  lockFiles.forEach(lockFile => {
@@ -35,6 +36,7 @@ class Node extends base_1.BaseStrategy {
35
36
  createIfMissing: false,
36
37
  updater: new package_lock_json_1.PackageLockJson({
37
38
  version,
39
+ versionsMap,
38
40
  }),
39
41
  });
40
42
  });
@@ -4,9 +4,10 @@ import { Commit } from '../commit';
4
4
  import { Release } from '../release';
5
5
  import { ReleasePullRequest } from '../release-pull-request';
6
6
  import { PullRequestBody } from '../util/pull-request-body';
7
+ import { BumpReleaseOptions } from '../strategy';
7
8
  export declare class PHPYoshi extends BaseStrategy {
8
9
  constructor(options: BaseStrategyOptions);
9
- buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
10
+ buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[], bumpOnlyOptions?: BumpReleaseOptions): Promise<ReleasePullRequest | undefined>;
10
11
  protected parsePullRequestBody(pullRequestBody: string): Promise<PullRequestBody | undefined>;
11
12
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
12
13
  }
@@ -48,10 +48,10 @@ class PHPYoshi extends base_1.BaseStrategy {
48
48
  changelogSections: CHANGELOG_SECTIONS,
49
49
  });
50
50
  }
51
- async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
51
+ async buildReleasePullRequest(commits, latestRelease, draft, labels = [], bumpOnlyOptions) {
52
52
  var _a, _b, _c;
53
53
  const conventionalCommits = await this.postProcessCommits((0, commit_1.parseConventionalCommits)(commits, this.logger));
54
- if (conventionalCommits.length === 0) {
54
+ if (!bumpOnlyOptions && conventionalCommits.length === 0) {
55
55
  this.logger.info(`No commits for path: ${this.path}, skipping`);
56
56
  return undefined;
57
57
  }
@@ -8,6 +8,9 @@ import { Version } from './version';
8
8
  export interface BuildReleaseOptions {
9
9
  groupPullRequestTitlePattern?: string;
10
10
  }
11
+ export interface BumpReleaseOptions {
12
+ newVersion: Version;
13
+ }
11
14
  /**
12
15
  * A strategy is responsible for determining which files are
13
16
  * necessary to update in a release pull request.
@@ -23,11 +26,15 @@ export interface Strategy {
23
26
  * component if available.
24
27
  * @param {boolean} draft Optional. Whether or not to create the pull
25
28
  * request as a draft. Defaults to `false`.
29
+ * @param {BumpReleaseOptions} bumpOnlyOptions Optional. Options, that when
30
+ * present, indicate a release should be created even if there are no
31
+ * conventional commits. This is used when a release is required for
32
+ * a dependency update with a workspace plugin.
26
33
  * @returns {ReleasePullRequest | undefined} The release pull request to
27
34
  * open for this path/component. Returns undefined if we should not
28
35
  * open a pull request.
29
36
  */
30
- buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
37
+ buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[], bumpOnlyOptions?: BumpReleaseOptions): Promise<ReleasePullRequest | undefined>;
31
38
  /**
32
39
  * Given a merged pull request, build the candidate release.
33
40
  * @param {PullRequest} mergedPullRequest The merged release pull request.
@@ -1,6 +1,16 @@
1
1
  import { Logger } from '../../util/logger';
2
+ import { Version, VersionsMap } from '../../version';
2
3
  import { DefaultUpdater } from '../default';
3
- import { Version } from '../../version';
4
+ export type PackageJsonDescriptor = {
5
+ name?: string;
6
+ resolved?: string;
7
+ link?: boolean;
8
+ version: string;
9
+ dependencies?: Record<string, string>;
10
+ devDependencies?: Record<string, string>;
11
+ peerDependencies?: Record<string, string>;
12
+ optionalDependencies?: Record<string, string>;
13
+ };
4
14
  /**
5
15
  * This updates a Node.js package.json file's main version.
6
16
  */
@@ -8,6 +18,7 @@ export declare class PackageJson extends DefaultUpdater {
8
18
  /**
9
19
  * Given initial file contents, return updated contents.
10
20
  * @param {string} content The initial content
21
+ * @param logger
11
22
  * @returns {string} The updated content
12
23
  */
13
24
  updateContent(content: string, logger?: Logger): string;
@@ -19,3 +30,11 @@ export declare class PackageJson extends DefaultUpdater {
19
30
  * @param {Version} newVersion The new version to update with
20
31
  */
21
32
  export declare function newVersionWithRange(oldVersion: string, newVersion: Version): string;
33
+ /**
34
+ * Helper function to update dependency versions for all new versions specified
35
+ * in the updated versions map. Note that this mutates the existing input.
36
+ * @param {Record<string, string>} dependencies Entries in package.json dependencies
37
+ * where the key is the dependency name and the value is the dependency range
38
+ * @param {VersionsMap} updatedVersions Map of new versions (without dependency range prefixes)
39
+ */
40
+ export declare function updateDependencies(dependencies: Record<string, string>, updatedVersions: VersionsMap): void;
@@ -13,7 +13,7 @@
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.newVersionWithRange = exports.PackageJson = void 0;
16
+ exports.updateDependencies = exports.newVersionWithRange = exports.PackageJson = void 0;
17
17
  const json_stringify_1 = require("../../util/json-stringify");
18
18
  const logger_1 = require("../../util/logger");
19
19
  const default_1 = require("../default");
@@ -24,6 +24,7 @@ class PackageJson extends default_1.DefaultUpdater {
24
24
  /**
25
25
  * Given initial file contents, return updated contents.
26
26
  * @param {string} content The initial content
27
+ * @param logger
27
28
  * @returns {string} The updated content
28
29
  */
29
30
  updateContent(content, logger = logger_1.logger) {
@@ -88,9 +89,9 @@ function updateDependencies(dependencies, updatedVersions) {
88
89
  const newVersion = updatedVersions.get(depName);
89
90
  if (newVersion) {
90
91
  const oldVersion = dependencies[depName];
91
- const newVersionString = newVersionWithRange(oldVersion, newVersion);
92
- dependencies[depName] = newVersionString;
92
+ dependencies[depName] = newVersionWithRange(oldVersion, newVersion);
93
93
  }
94
94
  }
95
95
  }
96
+ exports.updateDependencies = updateDependencies;
96
97
  //# sourceMappingURL=package-json.js.map
@@ -1,9 +1,14 @@
1
+ import { Updater } from '../../update';
1
2
  import { Logger } from '../../util/logger';
2
- import { DefaultUpdater } from '../default';
3
+ import { Version, VersionsMap } from '../../version';
4
+ import { UpdateOptions } from '../default';
3
5
  /**
4
6
  * Updates a Node.js package-lock.json file's version and '' package
5
7
  * version (for a v2 lock file).
6
8
  */
7
- export declare class PackageLockJson extends DefaultUpdater {
9
+ export declare class PackageLockJson implements Updater {
10
+ version?: Version;
11
+ versionsMap?: VersionsMap;
12
+ constructor(options: Partial<UpdateOptions>);
8
13
  updateContent(content: string, logger?: Logger): string;
9
14
  }
@@ -16,21 +16,60 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.PackageLockJson = void 0;
17
17
  const json_stringify_1 = require("../../util/json-stringify");
18
18
  const logger_1 = require("../../util/logger");
19
- const default_1 = require("../default");
19
+ const package_json_1 = require("./package-json");
20
20
  /**
21
21
  * Updates a Node.js package-lock.json file's version and '' package
22
22
  * version (for a v2 lock file).
23
23
  */
24
- class PackageLockJson extends default_1.DefaultUpdater {
24
+ class PackageLockJson {
25
+ constructor(options) {
26
+ this.version = options.version;
27
+ this.versionsMap = options.versionsMap;
28
+ }
25
29
  updateContent(content, logger = logger_1.logger) {
26
30
  const parsed = JSON.parse(content);
27
- logger.info(`updating from ${parsed.version} to ${this.version}`);
28
- parsed.version = this.version.toString();
31
+ if (this.version) {
32
+ logger.info(`updating from ${parsed.version} to ${this.version}`);
33
+ parsed.version = this.version.toString();
34
+ }
29
35
  if (parsed.lockfileVersion === 2 || parsed.lockfileVersion === 3) {
30
- parsed.packages[''].version = this.version.toString();
36
+ if (this.version) {
37
+ parsed.packages[''].version = this.version.toString();
38
+ }
39
+ if (this.versionsMap) {
40
+ this.versionsMap.forEach((version, name) => {
41
+ let pkg = parsed.packages['node_modules/' + name];
42
+ if (!pkg) {
43
+ return;
44
+ }
45
+ // @see https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#packages
46
+ if (pkg.link && pkg.resolved) {
47
+ pkg = parsed.packages[pkg.resolved];
48
+ if (!pkg) {
49
+ return;
50
+ }
51
+ }
52
+ pkg.version = version.toString();
53
+ if (pkg.dependencies) {
54
+ (0, package_json_1.updateDependencies)(pkg.dependencies, this.versionsMap);
55
+ }
56
+ if (pkg.devDependencies) {
57
+ (0, package_json_1.updateDependencies)(pkg.devDependencies, this.versionsMap);
58
+ }
59
+ if (pkg.peerDependencies) {
60
+ (0, package_json_1.updateDependencies)(pkg.peerDependencies, this.versionsMap);
61
+ }
62
+ if (pkg.optionalDependencies) {
63
+ (0, package_json_1.updateDependencies)(pkg.optionalDependencies, this.versionsMap);
64
+ }
65
+ });
66
+ }
31
67
  }
32
68
  if (this.versionsMap) {
33
69
  for (const [, obj] of Object.entries(parsed.packages)) {
70
+ if (!obj.name) {
71
+ continue;
72
+ }
34
73
  const ver = this.versionsMap.get(obj.name);
35
74
  if (ver) {
36
75
  obj.version = ver.toString();
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "16.5.1",
3
+ "version": "16.7.0",
4
4
  "description": "generate release PRs based on the conventionalcommits.org spec",
5
5
  "main": "./build/src/index.js",
6
6
  "bin": "./build/src/bin/release-please.js",
7
7
  "scripts": {
8
8
  "test": "cross-env ENVIRONMENT=test LC_ALL=en c8 mocha --node-option no-experimental-fetch --recursive --timeout=5000 build/test",
9
9
  "docs": "echo add docs tests",
10
- "test:snap": "SNAPSHOT_UPDATE=1 LC_ALL=en npm test",
10
+ "test:snap": "cross-env SNAPSHOT_UPDATE=1 LC_ALL=en npm test",
11
11
  "clean": "gts clean",
12
12
  "prepare": "npm run compile",
13
13
  "lint": "gts check",