-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(manager/mint): add mint support (#17351)
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
1 parent
8af1f08
commit 7dbe0b3
Showing
5 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
], | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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$'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |