Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
eb34049
feat(bundler): Switch to `ast-grep` parser
zharinov Jul 24, 2025
19725f4
Refactor
zharinov Jul 25, 2025
1d99b44
Fixes
zharinov Jul 25, 2025
1784aef
Variables
zharinov Jul 25, 2025
26413a1
Fix signature
zharinov Jul 25, 2025
52325a3
Fix tests
zharinov Jul 25, 2025
7dc813a
Remove local package tests from bundler parser
zharinov Jul 25, 2025
55d7c39
Merge branch 'main' into feat/bundler-ast-grep-parser
zharinov Jul 25, 2025
3457e47
Fix lockfile
zharinov Jul 25, 2025
f9698ed
Fix line numbers
zharinov Jul 25, 2025
9f44faf
Fix snapshots
zharinov Jul 25, 2025
84f36c7
Fix autoreplace
zharinov Jul 25, 2025
5dbc83c
Fix CI
zharinov Jul 25, 2025
eff96c7
Refactor
zharinov Jul 25, 2025
4f3b0df
Replace GitRefData interface with type from PackageDependency
zharinov Jul 25, 2025
87d5e8f
Rename bundler Ruby version parser files
zharinov Jul 25, 2025
1ff7e7b
Refactor
zharinov Jul 25, 2025
e158f98
Fix coverage
zharinov Jul 25, 2025
d486fa9
Refactor
zharinov Jul 25, 2025
3de61d7
Update git.spec.ts
zharinov Jul 25, 2025
e0ee628
Refactor
zharinov Jul 25, 2025
e2a8f8f
Add support for boolean key-value args in Bundler parser
zharinov Jul 25, 2025
94e0359
Add support for optional gem groups
zharinov Jul 25, 2025
16b412a
Add support for double Ruby version range extraction
zharinov Jul 25, 2025
68f05b0
Merge branch 'main' into feat/bundler-ast-grep-parser
zharinov Jul 25, 2025
42c93ee
Merge branch 'main' into feat/bundler-ast-grep-parser
zharinov Aug 1, 2025
60767c1
Merge branch 'main' into feat/bundler-ast-grep-parser
zharinov Aug 4, 2025
c4dbf0e
Remove skipReason from Bundler parser and extract tests
zharinov Aug 6, 2025
d9fe3a7
Bump @ast-grep/napi from 0.39.1 to 0.39.3
zharinov Aug 6, 2025
33fec4a
Remove unused common-tags import
zharinov Aug 6, 2025
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
1,247 changes: 516 additions & 731 deletions lib/modules/manager/bundler/__snapshots__/extract.spec.ts.snap

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions lib/modules/manager/bundler/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
import { regEx } from '../../../util/regex';
import type { UpdateArtifact } from '../types';

export const delimiters = ['"', "'"];

export function extractRubyVersion(txt: string): string | null {
const rubyMatch = regEx(/^ruby\s+("[^"]+"|'[^']+')\s*$/gm).exec(txt);
if (rubyMatch?.length !== 2) {
Expand Down
79 changes: 62 additions & 17 deletions lib/modules/manager/bundler/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ const sourceBlockWithNewLinesGemfileLock = Fixtures.get(
const sourceBlockWithNewLinesGemfile = Fixtures.get(
'Gemfile.sourceBlockWithNewLines',
);
const sourceBlockWithGroupsGemfile = Fixtures.get(
'Gemfile.sourceBlockWithGroups',
);

describe('modules/manager/bundler/extract', () => {
describe('extractPackageFile()', () => {
Expand Down Expand Up @@ -85,7 +82,7 @@ describe('modules/manager/bundler/extract', () => {
(dep) => is.string(dep.lockedVersion) && isValid(dep.lockedVersion),
),
).toBeTrue();
expect(res?.deps).toHaveLength(125);
expect(res?.deps).toHaveLength(126);
});

it('parse Ruby CI Gemfile', async () => {
Expand Down Expand Up @@ -130,16 +127,57 @@ describe('modules/manager/bundler/extract', () => {
});

it('parses source blocks with groups in Gemfile', async () => {
fs.readLocalFile.mockResolvedValueOnce(sourceBlockWithGroupsGemfile);
const res = await extractPackageFile(
sourceBlockWithGroupsGemfile,
'Gemfile',
);
const source = codeBlock`
source 'https://hub.tech.my.domain.de/artifactory/api/gems/my-gems-prod-local/' do
gem 'sfn_my_dep1', "~> 1"
gem 'sfn_my_dep2', "~> 1"

group :test, :development do
gem 'internal_test_gem', "~> 1"
end

group :production do
gem 'internal_production_gem', "~> 1"
end
end
`;
fs.readLocalFile.mockResolvedValueOnce(source);
const res = await extractPackageFile(source, 'Gemfile');
expect(res?.deps).toMatchObject([
{ depName: 'internal_test_gem', currentValue: '"~> 1"' },
{ depName: 'internal_production_gem', currentValue: '"~> 1"' },
{ depName: 'sfn_my_dep1', currentValue: '"~> 1"' },
{ depName: 'sfn_my_dep2', currentValue: '"~> 1"' },
{
currentValue: '~> 1',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, we extract without quotes. you need to check the ruby versioning if it needs the quotes!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It strips them when needed

datasource: 'rubygems',
depName: 'sfn_my_dep1',
registryUrls: [
'https://hub.tech.my.domain.de/artifactory/api/gems/my-gems-prod-local/',
],
},
{
currentValue: '~> 1',
datasource: 'rubygems',
depName: 'sfn_my_dep2',
registryUrls: [
'https://hub.tech.my.domain.de/artifactory/api/gems/my-gems-prod-local/',
],
},
{
currentValue: '~> 1',
datasource: 'rubygems',
depName: 'internal_test_gem',
depTypes: ['test', 'development'],
registryUrls: [
'https://hub.tech.my.domain.de/artifactory/api/gems/my-gems-prod-local/',
],
},
{
currentValue: '~> 1',
datasource: 'rubygems',
depName: 'internal_production_gem',
depType: 'production',
registryUrls: [
'https://hub.tech.my.domain.de/artifactory/api/gems/my-gems-prod-local/',
],
},
]);
});

Expand Down Expand Up @@ -193,7 +231,7 @@ describe('modules/manager/bundler/extract', () => {
},
{
depName: 'inline_source_gem_with_version',
currentValue: '"~> 1"',
currentValue: '~> 1',
registryUrls: ['https://gems.bar.com'],
},
{
Expand Down Expand Up @@ -225,7 +263,7 @@ describe('modules/manager/bundler/extract', () => {
gem 'foo', git: 'https://github.com/foo/foo', ref: 'fd184883048b922b176939f851338d0a4971a532'
gem 'bar', git: 'https://github.com/bar/bar', tag: 'v1.0.0'
gem 'baz', github: 'baz/baz', branch: 'master'
`;
`;

fs.readLocalFile.mockResolvedValueOnce(gitRefGemfile);
const res = await extractPackageFile(gitRefGemfile, 'Gemfile');
Expand Down Expand Up @@ -267,17 +305,24 @@ describe('modules/manager/bundler/extract', () => {
expect(res).toMatchObject({
deps: [
{
datasource: 'rubygems',
depName: 'gem_without_values',
skipReason: 'unspecified-version',
},
{
currentValue: '>= 3.0.5',
datasource: 'rubygems',
depName: 'gem_with_one_value',
currentValue: '">= 3.0.5"',
skipReason: 'unknown-registry',
},
{
depName: 'gem_with_multiple_values',
currentValue: '">= 3.0.5", "< 3.2"',
datasource: 'rubygems',
depName: 'gem_with_multiple_values',
skipReason: 'unknown-registry',
},
],
lockFiles: ['Gemfile.lock'],
});
});

Expand Down
Loading
Loading