Skip to content

Commit

Permalink
feat: support gem backend
Browse files Browse the repository at this point in the history
  • Loading branch information
risu729 committed Dec 27, 2024
1 parent 60a025b commit 37aa7ae
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/modules/manager/mise/backends.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ describe('modules/manager/mise/backends', () => {
});
});

describe('createGemToolConfig()', () => {
it('should create a tooling config', () => {
expect(createGoToolConfig('rubocop')).toStrictEqual({
packageName: 'rubocop',
datasource: 'rubygems',
});
});
});

describe('createGoToolConfig()', () => {
it('should create a tooling config', () => {
expect(createGoToolConfig('github.com/DarthSim/hivemind')).toStrictEqual({
Expand Down
14 changes: 14 additions & 0 deletions lib/modules/manager/mise/backends.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { normalizePythonDepName } from '../../datasource/pypi/common';
import type { PackageDependency } from '../types';
import type { MiseToolOptionsSchema } from './schema';
import { NugetDatasource } from '../../datasource/nuget';
import { RubygemsDatasource } from '../../datasource/rubygems';

export type BackendToolingConfig = Omit<PackageDependency, 'depName'> &
Required<
Expand Down Expand Up @@ -100,6 +101,19 @@ export function createDotnetToolConfig(
};
}

/**
* Create a tooling config for gem backend
* @link https://mise.jdx.dev/dev-tools/backends/gem.html
*/
export function createGemToolConfig(
name: string,
): BackendToolingConfig {
return {
packageName: name,
datasource: RubygemsDatasource.id,
};
}

/**
* Create a tooling config for go backend
* @link https://mise.jdx.dev/dev-tools/backends/go.html
Expand Down
18 changes: 18 additions & 0 deletions lib/modules/manager/mise/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,24 @@ describe('modules/manager/mise/extract', () => {
});
});

it('extracts gem backend tool', () => {
const content = codeBlock`
[tools]
"gem:rubocop" = "1.69.2"
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'gem:rubocop',
currentValue: '1.69.2',
packageName: 'rubocop',
datasource: 'rubygems',
},
],
});
});

it('extracts go backend tool', () => {
const content = codeBlock`
[tools]
Expand Down
3 changes: 3 additions & 0 deletions lib/modules/manager/mise/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
createAquaToolConfig,
createCargoToolConfig,
createDotnetToolConfig,
createGemToolConfig,
createGoToolConfig,
createNpmToolConfig,
createPipxToolConfig,
Expand Down Expand Up @@ -125,6 +126,8 @@ function getToolConfig(
return createCargoToolConfig(toolName, version);
case 'dotnet':
return createDotnetToolConfig(toolName);
case 'gem':
return createGemToolConfig(toolName);
case 'go':
return createGoToolConfig(toolName);
case 'npm':
Expand Down
2 changes: 2 additions & 0 deletions lib/modules/manager/mise/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { NpmDatasource } from '../../datasource/npm';
import { NugetDatasource } from '../../datasource/nuget';
import { PypiDatasource } from '../../datasource/pypi';
import { RubyVersionDatasource } from '../../datasource/ruby-version';
import { RubygemsDatasource } from '../../datasource/rubygems';
import { supportedDatasources as asdfSupportedDatasources } from '../asdf';

export { extractPackageFile } from './extract';
Expand All @@ -35,6 +36,7 @@ const backendDatasources = {
aqua: [GithubTagsDatasource.id],
cargo: [CrateDatasource.id, GitTagsDatasource.id, GitRefsDatasource.id],
dotnet: [NugetDatasource.id],
gem: [RubygemsDatasource.id],
go: [GoDatasource.id],
npm: [NpmDatasource.id],
pipx: [PypiDatasource.id, GithubTagsDatasource.id, GitRefsDatasource.id],
Expand Down

0 comments on commit 37aa7ae

Please sign in to comment.