Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions __snapshots__/bun-lock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
exports['BunLock updateContent monorepo updates workspace versions 1'] = `
{
"lockfileVersion": 1,
"configVersion": 1,
"workspaces": {
"": {
"name": "release-please",
"version": "14.0.0",
},
"packages/foo": {
"name": "release-please-foo",
"version": "2.0.0",
"dependencies": {
"release-please-bar": "workspace:*",
},
},
"packages/bar": {
"name": "release-please-bar",
"version": "3.0.0",
},
},
}

`
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"http-proxy-agent": "^7.0.0",
"https-proxy-agent": "^7.0.0",
"js-yaml": "^4.0.0",
"jsonc-parser": "^3.3.1",
"jsonpath-plus": "^10.0.0",
"node-html-parser": "^6.0.0",
"parse-github-repo-url": "^1.4.1",
Expand Down
9 changes: 9 additions & 0 deletions src/strategies/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {BaseStrategy, BuildUpdatesOptions} from './base';
import {Update} from '../update';
import {ChangelogJson} from '../updaters/changelog-json';
import {PackageLockJson} from '../updaters/node/package-lock-json';
import {BunLock} from '../updaters/node/bun-lock';
import {SamplesPackageJson} from '../updaters/node/samples-package-json';
import {Changelog} from '../updaters/changelog';
import {PackageJson} from '../updaters/node/package-json';
Expand Down Expand Up @@ -45,6 +46,14 @@ export class Node extends BaseStrategy {
});
});

updates.push({
path: this.addPath('bun.lock'),
createIfMissing: false,
updater: new BunLock({
versionsMap,
}),
});

updates.push({
path: this.addPath('samples/package.json'),
createIfMissing: false,
Expand Down
66 changes: 66 additions & 0 deletions src/updaters/node/bun-lock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import {Updater} from '../../update';
import {VersionsMap} from '../../version';
import {logger as defaultLogger, Logger} from '../../util/logger';
import {UpdateOptions} from '../default';
import {modify, applyEdits, parse} from 'jsonc-parser';

interface BunWorkspace {
name: string;
version?: string;
}

interface BunLockData {
workspaces: Record<string, BunWorkspace>;
}

export class BunLock implements Updater {
versionsMap?: VersionsMap;

constructor(options: Partial<UpdateOptions>) {
this.versionsMap = options.versionsMap;
}

updateContent(content: string, logger: Logger = defaultLogger): string {
if (!this.versionsMap) {
return content;
}

const parsed = parse(content, [], {
allowTrailingComma: true,
}) as BunLockData;

const edits = [];
for (const [path, workspace] of Object.entries(parsed.workspaces)) {
if (!workspace.name) continue;

const version = this.versionsMap.get(workspace.name);
if (version) {
logger.info(`updating from ${workspace.version} to ${version}`);
edits.push(
...modify(
content,
['workspaces', path, 'version'],
version.toString(),
{formattingOptions: {insertSpaces: true, tabSize: 2}}
)
);
}
}

return applyEdits(content, edits);
}
}
43 changes: 43 additions & 0 deletions test/updaters/bun-lock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import {readFileSync} from 'fs';
import {resolve} from 'path';
import * as snapshot from 'snap-shot-it';
import {describe, it} from 'mocha';
import {BunLock} from '../../src/updaters/node/bun-lock';
import {Version} from '../../src/version';

const fixturesPath = './test/updaters/fixtures';

describe('BunLock', () => {
describe('updateContent monorepo', () => {
it('updates workspace versions', async () => {
const oldContent = readFileSync(
resolve(fixturesPath, './bun.lock'),
'utf8'
);
const versionsMap = new Map();
versionsMap.set('release-please', new Version(14, 0, 0));
versionsMap.set('release-please-foo', new Version(2, 0, 0));
versionsMap.set('release-please-bar', new Version(3, 0, 0));
const bunLock = new BunLock({
version: Version.parse('14.0.0'),
versionsMap,
});
const newContent = bunLock.updateContent(oldContent);
snapshot(newContent.replace(/\r\n/g, '\n'));
});
});
});
20 changes: 20 additions & 0 deletions test/updaters/fixtures/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading