Skip to content

Commit

Permalink
feat(manager/mint): add mint support (#17351)
Browse files Browse the repository at this point in the history
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
  • Loading branch information
4 people committed Sep 6, 2022
1 parent 8af1f08 commit 7dbe0b3
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/modules/manager/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import * as kustomize from './kustomize';
import * as leiningen from './leiningen';
import * as maven from './maven';
import * as meteor from './meteor';
import * as mint from './mint';
import * as mix from './mix';
import * as nodenv from './nodenv';
import * as npm from './npm';
Expand Down Expand Up @@ -126,6 +127,7 @@ api.set('kustomize', kustomize);
api.set('leiningen', leiningen);
api.set('maven', maven);
api.set('meteor', meteor);
api.set('mint', mint);
api.set('mix', mix);
api.set('nodenv', nodenv);
api.set('npm', npm);
Expand Down
119 changes: 119 additions & 0 deletions lib/modules/manager/mint/extract.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { extractPackageFile } from '.';

const simpleMintfile = `
SwiftGen/SwiftGen@6.6.1
yonaskolb/xcodegen@2.30.0
realm/SwiftLint @ 0.48.0
#realm/SwiftLint @ 0.48.0
`;

const noVersionMintfileContent = `
yonaskolb/xcodegen
realm/SwiftLint
`;

const complexMintFileContent = `
SwiftGen/SwiftGen@6.6.1
yonaskolb/xcodegen
realm/SwiftLint @ 0.48.0`;

const includesCommentedOutMintFileContent = `
SwiftGen/SwiftGen@6.6.1
yonaskolb/xcodegen
#yonaskolb/xcodegen
realm/SwiftLint@0.48.0 #commented out
`;

describe('modules/manager/mint/extract', () => {
describe('extractPackageFile()', () => {
it('Mintfile With Version Description', () => {
const res = extractPackageFile(simpleMintfile);
expect(res).toEqual({
deps: [
{
depName: 'SwiftGen/SwiftGen',
currentValue: '6.6.1',
datasource: 'git-tags',
packageName: 'https://github.com/SwiftGen/SwiftGen.git',
},
{
depName: 'yonaskolb/xcodegen',
currentValue: '2.30.0',
datasource: 'git-tags',
packageName: 'https://github.com/yonaskolb/xcodegen.git',
},
{
depName: 'realm/SwiftLint',
currentValue: '0.48.0',
datasource: 'git-tags',
packageName: 'https://github.com/realm/SwiftLint.git',
},
],
});
});

it('Mintfile Without Version Description', () => {
const res = extractPackageFile(noVersionMintfileContent);
expect(res).toEqual({
deps: [
{
depName: 'yonaskolb/xcodegen',
skipReason: 'no-version',
},
{
depName: 'realm/SwiftLint',
skipReason: 'no-version',
},
],
});
});

it('Complex Mintfile', () => {
const res = extractPackageFile(complexMintFileContent);
expect(res).toEqual({
deps: [
{
depName: 'SwiftGen/SwiftGen',
currentValue: '6.6.1',
datasource: 'git-tags',
packageName: 'https://github.com/SwiftGen/SwiftGen.git',
},
{
depName: 'yonaskolb/xcodegen',
skipReason: 'no-version',
},
{
depName: 'realm/SwiftLint',
currentValue: '0.48.0',
datasource: 'git-tags',
packageName: 'https://github.com/realm/SwiftLint.git',
},
],
});
});

it('Mintfile Includes Commented Out', () => {
const res = extractPackageFile(includesCommentedOutMintFileContent);
expect(res).toEqual({
deps: [
{
depName: 'SwiftGen/SwiftGen',
currentValue: '6.6.1',
datasource: 'git-tags',
packageName: 'https://github.com/SwiftGen/SwiftGen.git',
},
{
depName: 'yonaskolb/xcodegen',
skipReason: 'no-version',
},
{
depName: 'realm/SwiftLint',
currentValue: '0.48.0',
datasource: 'git-tags',
packageName: 'https://github.com/realm/SwiftLint.git',
},
],
});
});
});
});
44 changes: 44 additions & 0 deletions lib/modules/manager/mint/extract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { newlineRegex } from '../../../util/regex';
import { GitTagsDatasource } from '../../datasource/git-tags';
import type { PackageDependency, PackageFile } from '../types';

export function extractPackageFile(content: string): PackageFile | null {
const deps: PackageDependency[] = [];

for (const line of content.split(newlineRegex).map((s) => s.trim())) {
if (line === '') {
continue;
}

// commented out line
if (line.startsWith('#')) {
continue;
}

// commented out line after package name
if (line.includes('#')) {
const [uncommentLine] = line.split('#');
deps.push(handleDepInMintfile(uncommentLine));
continue;
}

deps.push(handleDepInMintfile(line));
}
return deps.length ? { deps } : null;
}

function handleDepInMintfile(line: string): PackageDependency {
if (!line.includes('@')) {
return {
depName: line,
skipReason: 'no-version',
};
}
const [depName, currentVersion] = line.split('@').map((s) => s.trim());
return {
depName: depName,
currentValue: currentVersion,
datasource: GitTagsDatasource.id,
packageName: `https://github.com/${depName}.git`,
};
}
12 changes: 12 additions & 0 deletions lib/modules/manager/mint/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { GitTagsDatasource } from '../../datasource/git-tags';

export const displayName = 'Mint';
export const url = 'https://github.com/yonaskolb/Mint';

export { extractPackageFile } from './extract';

export const supportedDatasources = [GitTagsDatasource.id];

export const defaultConfig = {
fileMatch: ['(^|\\/)Mintfile$'],
};
14 changes: 14 additions & 0 deletions lib/modules/manager/mint/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Renovate supports updating Mintfiles.

Go to the [`yonaskolb/Mint` repository on GitHub](https://github.com/yonaskolb/Mint) to learn more about the Mint package manager.

You must put the library version in the Mintfile:

```
// Good:
SwiftGen/SwiftGen@6.6.1
realm/SwiftLint @ 0.48.0
// Bad:
yonaskolb/xcodegen
```

0 comments on commit 7dbe0b3

Please sign in to comment.