Skip to content

Commit

Permalink
feat(manager): support mise backends
Browse files Browse the repository at this point in the history
  • Loading branch information
risu729 committed Dec 14, 2024
1 parent 098c3e2 commit e811461
Show file tree
Hide file tree
Showing 5 changed files with 591 additions and 17 deletions.
275 changes: 275 additions & 0 deletions lib/modules/manager/mise/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,281 @@ describe('modules/manager/mise/extract', () => {
});
});

it('extracts tools in the default registry with backends', () => {
const content = codeBlock`
[tools]
"core:node" = "16"
"asdf:rust" = "1.82.0"
"vfox:scala" = "3.5.2"
"aqua:act" = "0.2.70"
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'core:node',
currentValue: '16',
packageName: 'nodejs',
datasource: 'node-version',
},
{
depName: 'asdf:rust',
currentValue: '1.82.0',
packageName: 'rust-lang/rust',
datasource: 'github-tags',
},
{
depName: 'vfox:scala',
currentValue: '3.5.2',
packageName: 'lampepfl/dotty',
datasource: 'github-tags',
},
{
depName: 'aqua:act',
currentValue: '0.2.70',
packageName: 'nektos/act',
datasource: 'github-releases',
},
],
});
});

it('extracts aqua backend tool', () => {
const content = codeBlock`
[tools]
"aqua:BurntSushi/ripgrep" = "14.1.0"
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'aqua:BurntSushi/ripgrep',
currentValue: '14.1.0',
packageName: 'BurntSushi/ripgrep',
datasource: 'github-tags',
},
],
});
});

it('extracts cargo backend tools', () => {
const content = codeBlock`
[tools]
"cargo:eza" = "0.18.21"
"cargo:https://github.com/username/demo1" = "tag:v0.1.0"
"cargo:https://github.com/username/demo2" = "branch:main"
"cargo:https://github.com/username/demo3" = "rev:abcdef"
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'cargo:eza',
currentValue: '0.18.21',
packageName: 'eza',
datasource: 'crate',
},
{
depName: 'cargo:https://github.com/username/demo1',
packageName: 'https://github.com/username/demo1',
skipReason: 'unsupported-url',
},
{
depName: 'cargo:https://github.com/username/demo2',
packageName: 'https://github.com/username/demo2',
skipReason: 'unsupported-url',
},
{
depName: 'cargo:https://github.com/username/demo3',
packageName: 'https://github.com/username/demo3',
skipReason: 'unsupported-url',
},
],
});
});

it('extracts go backend tool', () => {
const content = codeBlock`
[tools]
"go:github.com/DarthSim/hivemind" = "1.0.6"
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'go:github.com/DarthSim/hivemind',
currentValue: '1.0.6',
packageName: 'github.com/DarthSim/hivemind',
datasource: 'go',
},
],
});
});

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

it('extracts pipx backend tools', () => {
const content = codeBlock`
[tools]
"pipx:yamllint" = "1.35.0"
"pipx:psf/black" = "24.4.1"
"pipx:git+https://github.com/psf/black.git" = "24.4.1"
"pipx:git+https://gitlab.com/user/repo.git" = "0.1.0"
# Does not work but the mise docs says supporting
"pipx:https://github.com/psf/black/archive/18.9b0.zip" = "latest"
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'pipx:yamllint',
currentValue: '1.35.0',
packageName: 'yamllint',
datasource: 'pypi',
},
{
depName: 'pipx:psf/black',
currentValue: '24.4.1',
packageName: 'psf/black',
datasource: 'github-tags',
},
{
depName: 'pipx:git+https://github.com/psf/black.git',
currentValue: '24.4.1',
packageName: 'psf/black',
datasource: 'github-tags',
},
{
depName: 'pipx:git+https://gitlab.com/user/repo.git',
packageName: 'git+https://gitlab.com/user/repo.git',
skipReason: 'unsupported-url',
},
{
depName: 'pipx:https://github.com/psf/black/archive/18.9b0.zip',
packageName: 'https://github.com/psf/black/archive/18.9b0.zip',
skipReason: 'unsupported-url',
},
],
});
});

it('extracts spm backend tools', () => {
const content = codeBlock`
[tools]
"spm:tuist/tuist" = "4.15.0"
"spm:https://github.com/tuist/tuist.git" = "4.13.0"
"spm:https://gitlab.com/user/repo.git" = "0.1.0"
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'spm:tuist/tuist',
currentValue: '4.15.0',
packageName: 'tuist/tuist',
datasource: 'github-releases',
},
{
depName: 'spm:https://github.com/tuist/tuist.git',
currentValue: '4.13.0',
packageName: 'tuist/tuist',
datasource: 'github-releases',
},
{
depName: 'spm:https://gitlab.com/user/repo.git',
packageName: 'https://gitlab.com/user/repo.git',
skipReason: 'unsupported-url',
},
],
});
});

it('extracts ubi backend tools', () => {
const content = codeBlock`
[tools]
"ubi:nekto/act" = "0.2.70"
"ubi:cli/cli" = { exe = "gh", version = "1.14.0" }
"ubi:cli/cli[exe=gh]" = "1.14.0"
"ubi:tamasfe/taplo" = { matching = "full", version = "0.1.0" }
"ubi:tamasfe/taplo[matching=full]" = "0.1.0"
"ubi:cargo-bins/cargo-binstall" = { tag_regex = "^\\d+\\.\\d+\\.", version = "1.0.0" }
"ubi:cargo-bins/cargo-binstall[tag_regex=^\\d+\\.]" = "1.0.0"
"ubi:cargo-bins/cargo-binstall[tag_regex=^\\d+\\.\\d+\\.]" = { tag_regex = "^\\d+\\.", version = "1.0.0" }
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({

Check failure on line 324 in lib/modules/manager/mise/extract.spec.ts

View workflow job for this annotation

GitHub Actions / test (1/1)

modules/manager/mise/extract › extractPackageFile() › extracts ubi backend tools

expect(received).toMatchObject(expected) Matcher error: received value must be a non-null object Received has value: null at Object.<anonymous> (lib/modules/manager/mise/extract.spec.ts:324:22)
deps: [
{
depName: 'ubi:nekto/act',
currentValue: '0.2.70',
packageName: 'nekto/act',
datasource: 'github-releases',
},
{
depName: 'ubi:cli/cli',
currentValue: '1.14.0',
packageName: 'cli/cli',
datasource: 'github-releases',
},
{
depName: 'ubi:cli/cli',
currentValue: '1.14.0',
packageName: 'cli/cli',
datasource: 'github-releases',
},
{
depName: 'ubi:tamasfe/taplo',
currentValue: '0.1.0',
packageName: 'tamasfe/taplo',
datasource: 'github-releases',
},
{
depName: 'ubi:tamasfe/taplo',
currentValue: '0.1.0',
packageName: 'tamasfe/taplo',
datasource: 'github-releases',
},
{
depName: 'ubi:cargo-bins/cargo-binstall',
currentValue: '1.0.0',
packageName: 'cargo-bins/cargo-binstall',
datasource: 'github-releases',
extractVersion: '(?<version>\\d+\\.\\d+\\.)',
},
{
depName: 'ubi:cargo-bins/cargo-binstall',
currentValue: '1.0.0',
packageName: 'cargo-bins/cargo-binstall',
datasource: 'github-releases',
extractVersion: '(?<version>\\d+\\.)',
},
{
depName: 'ubi:cargo-bins/cargo-binstall',
currentValue: '1.0.0',
packageName: 'cargo-bins/cargo-binstall',
datasource: 'github-releases',
extractVersion: '(?<version>\\d+\\.)',
},
],
});
});

it('provides skipReason for lines with unsupported tooling', () => {
const content = codeBlock`
[tools]
Expand Down
Loading

0 comments on commit e811461

Please sign in to comment.