Skip to content

Commit

Permalink
feat(manager): add mise package manager (#29950)
Browse files Browse the repository at this point in the history
  • Loading branch information
james0209 committed Jul 8, 2024
1 parent 0d6dfd1 commit 4a304b8
Show file tree
Hide file tree
Showing 13 changed files with 804 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/usage/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Renovate can manage the Node.js version in the following files:
- The [`.nvmrc`](https://github.com/creationix/nvm#nvmrc) file for the [Node Version Manager](https://github.com/creationix/nvm)
- The [`.node-version`](https://github.com/nodenv/nodenv#choosing-the-node-version) file for the [nodenv](https://github.com/nodenv/nodenv) environment manager
- The [`.tool-versions`](https://asdf-vm.com/manage/configuration.html#tool-versions) file for the [asdf](https://github.com/asdf-vm/asdf) version manager
- The [`.mise.toml`](https://mise.jdx.dev/configuration.html#mise-toml) file for the [mise](https://github.com/jdx/mise) version manager
- The [`node_js`](https://docs.travis-ci.com/user/languages/javascript-with-nodejs/#Specifying-Node.js-versions) field in [`.travis.yml`](https://docs.travis-ci.com/user/customizing-the-build/)

## Configuring which version of npm Renovate uses
Expand Down
2 changes: 2 additions & 0 deletions lib/modules/manager/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import * as maven from './maven';
import * as mavenWrapper from './maven-wrapper';
import * as meteor from './meteor';
import * as mint from './mint';
import * as mise from './mise';
import * as mix from './mix';
import * as nix from './nix';
import * as nodenv from './nodenv';
Expand Down Expand Up @@ -153,6 +154,7 @@ api.set('maven', maven);
api.set('maven-wrapper', mavenWrapper);
api.set('meteor', meteor);
api.set('mint', mint);
api.set('mise', mise);
api.set('mix', mix);
api.set('nix', nix);
api.set('nodenv', nodenv);
Expand Down
19 changes: 19 additions & 0 deletions lib/modules/manager/mise/__fixtures__/Mise.1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[env]
# supports arbitrary env vars so mise can be used like direnv/dotenv
NODE_ENV = 'production'

[tools]
# specify single or multiple versions
java = '21.0.2'
erlang = ['23.3', '24.0']

# supports everything you can do with .tool-versions currently
node = ['16', 'prefix:20', 'ref:master', 'path:~/.nodes/14']

[plugins]
# specify a custom repo URL
# note this will only be used if the plugin does not already exist
python = 'https://github.com/asdf-community/asdf-python'

[alias.node] # project-local aliases
my_custom_node = '20'
354 changes: 354 additions & 0 deletions lib/modules/manager/mise/extract.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,354 @@
import { codeBlock } from 'common-tags';
import { Fixtures } from '../../../../test/fixtures';
import { extractPackageFile } from '.';

jest.mock('../../../util/fs');

const miseFilename = '.mise.toml';

const mise1toml = Fixtures.get('Mise.1.toml');

describe('modules/manager/mise/extract', () => {
describe('extractPackageFile()', () => {
it('returns null for empty', () => {
expect(extractPackageFile('', miseFilename)).toBeNull();
});

it('returns null for invalid TOML', () => {
expect(extractPackageFile('foo', miseFilename)).toBeNull();
});

it('returns null for empty tools section', () => {
const content = codeBlock`
[tools]
`;
expect(extractPackageFile(content, miseFilename)).toBeNull();
});

it('extracts tools - mise core plugins', () => {
const content = codeBlock`
[tools]
erlang = '23.3'
node = '16'
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'erlang',
currentValue: '23.3',
datasource: 'github-tags',
},
{
depName: 'node',
currentValue: '16',
datasource: 'node-version',
},
],
});
});

it('extracts tools - asdf plugins', () => {
const content = codeBlock`
[tools]
terraform = '1.8.0'
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'terraform',
currentValue: '1.8.0',
},
],
});
});

it('extracts tools with multiple versions', () => {
const content = codeBlock`
[tools]
erlang = ['23.3', '24.0']
node = ['16', 'prefix:20', 'ref:master', 'path:~/.nodes/14']
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'erlang',
currentValue: '23.3',
datasource: 'github-tags',
},
{
depName: 'node',
currentValue: '16',
datasource: 'node-version',
},
],
});
});

it('extracts tools with plugin options', () => {
const content = codeBlock`
[tools]
python = {version='3.11', virtualenv='.venv'}
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'python',
currentValue: '3.11',
},
],
});
});

it('provides skipReason for lines with unsupported tooling', () => {
const content = codeBlock`
[tools]
fake-tool = '1.0.0'
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'fake-tool',
skipReason: 'unsupported-datasource',
},
],
});
});

it('provides skipReason for missing version - empty string', () => {
const content = codeBlock`
[tools]
python = ''
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'python',
skipReason: 'unspecified-version',
},
],
});
});

it('provides skipReason for missing version - missing version in object', () => {
const content = codeBlock`
[tools]
python = {virtualenv='.venv'}
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'python',
skipReason: 'unspecified-version',
},
],
});
});

it('provides skipReason for missing version - empty array', () => {
const content = codeBlock`
[tools]
java = '21.0.2'
erlang = []
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'java',
currentValue: '21.0.2',
},
{
depName: 'erlang',
skipReason: 'unspecified-version',
},
],
});
});

it('complete .mise.toml example', () => {
const result = extractPackageFile(mise1toml, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'java',
currentValue: '21.0.2',
datasource: 'java-version',
},
{
depName: 'erlang',
currentValue: '23.3',
datasource: 'github-tags',
},
{
depName: 'node',
currentValue: '16',
datasource: 'node-version',
},
],
});
});

it('complete example with skip', () => {
const content = codeBlock`
[tools]
java = '21.0.2'
erlang = ['23.3', '24.0']
terraform = {version='1.8.0'}
fake-tool = '1.6.2'
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'java',
currentValue: '21.0.2',
datasource: 'java-version',
},
{
depName: 'erlang',
currentValue: '23.3',
datasource: 'github-tags',
},
{
depName: 'terraform',
currentValue: '1.8.0',
},
{
depName: 'fake-tool',
skipReason: 'unsupported-datasource',
},
],
});
});

it('core java plugin function', () => {
const content = codeBlock`
[tools]
java = "21.0.2"
`;
const result = extractPackageFile(content, miseFilename);
expect(result).toMatchObject({
deps: [
{
depName: 'java',
currentValue: '21.0.2',
datasource: 'java-version',
},
],
});

const content2 = codeBlock`
[tools]
java = "openjdk-21.0.2"
`;
const result2 = extractPackageFile(content2, miseFilename);
expect(result2).toMatchObject({
deps: [
{
depName: 'java',
currentValue: '21.0.2',
datasource: 'java-version',
},
],
});

const content3 = codeBlock`
[tools]
java = "temurin-21.0.2"
`;
const result3 = extractPackageFile(content3, miseFilename);
expect(result3).toMatchObject({
deps: [
{
depName: 'java',
currentValue: '21.0.2',
datasource: 'java-version',
},
],
});

const content4 = codeBlock`
[tools]
java = "zulu-21.0.2"
`;
const result4 = extractPackageFile(content4, miseFilename);
expect(result4).toMatchObject({
deps: [
{
depName: 'java',
currentValue: '21.0.2',
datasource: 'java-version',
},
],
});

const content5 = codeBlock`
[tools]
java = "corretto-21.0.2"
`;
const result5 = extractPackageFile(content5, miseFilename);
expect(result5).toMatchObject({
deps: [
{
depName: 'java',
currentValue: '21.0.2',
datasource: 'java-version',
},
],
});

const content6 = codeBlock`
[tools]
java = "oracle-graalvm-21.0.2"
`;
const result6 = extractPackageFile(content6, miseFilename);
expect(result6).toMatchObject({
deps: [
{
depName: 'java',
currentValue: '21.0.2',
datasource: 'java-version',
},
],
});

const content7 = codeBlock`
[tools]
java = "adoptopenjdk-21.0.2"
`;
const result7 = extractPackageFile(content7, miseFilename);
expect(result7).toMatchObject({
deps: [
{
depName: 'java',
currentValue: '21.0.2',
datasource: 'java-version',
},
],
});

// Test that fallback to asdf Plugin works
const content8 = codeBlock`
[tools]
java = "adoptopenjdk-jre-16.0.0+36"
`;
const result8 = extractPackageFile(content8, miseFilename);
expect(result8).toMatchObject({
deps: [
{
depName: 'java',
currentValue: '16.0.0+36',
datasource: 'java-version',
},
],
});
});
});
});
Loading

0 comments on commit 4a304b8

Please sign in to comment.