-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(manager): add bun-version manager (#29998)
Co-authored-by: Rhys Arkins <[email protected]> Co-authored-by: Sebastian Poxhofer <[email protected]>
- Loading branch information
1 parent
a91d646
commit e064c5e
Showing
4 changed files
with
96 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,57 @@ | ||
import { extractPackageFile } from '.'; | ||
|
||
describe('modules/manager/bun-version/index', () => { | ||
describe('extractPackageFile()', () => { | ||
it('returns a result', () => { | ||
const res = extractPackageFile('1.1.15\n'); | ||
expect(res?.deps).toEqual([ | ||
{ | ||
depName: 'Bun', | ||
packageName: 'bun', | ||
currentValue: '1.1.15', | ||
datasource: 'npm', | ||
}, | ||
]); | ||
}); | ||
|
||
it('handles empty files', () => { | ||
const res = extractPackageFile(''); | ||
expect(res).toBeNull(); | ||
}); | ||
|
||
it('handles no newline at the end', () => { | ||
const res = extractPackageFile('1.1.15'); | ||
expect(res).not.toBeNull(); | ||
}); | ||
|
||
it('handles multiple lines', () => { | ||
const res = extractPackageFile('1.1.15\n1.1.16\n'); | ||
expect(res).toBeNull(); | ||
}); | ||
|
||
it('handles invalid versions', () => { | ||
const res = extractPackageFile('notaversion\n'); | ||
expect(res?.deps).toEqual([ | ||
{ | ||
depName: 'Bun', | ||
packageName: 'bun', | ||
currentValue: 'notaversion', | ||
datasource: 'npm', | ||
skipReason: 'invalid-version', | ||
}, | ||
]); | ||
}); | ||
|
||
it('handles ranges', () => { | ||
const res = extractPackageFile('1.0\n'); | ||
expect(res?.deps).toEqual([ | ||
{ | ||
depName: 'Bun', | ||
packageName: 'bun', | ||
currentValue: '1.0', | ||
datasource: 'npm', | ||
}, | ||
]); | ||
}); | ||
}); | ||
}); |
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,36 @@ | ||
import type { Category } from '../../../constants'; | ||
import { NpmDatasource } from '../../datasource/npm'; | ||
import { id, isValid } from '../../versioning/npm'; | ||
|
||
import type { PackageDependency, PackageFileContent } from '../types'; | ||
|
||
export const supportedDatasources = [NpmDatasource.id]; | ||
|
||
export const defaultConfig = { | ||
fileMatch: ['(^|/)\\.bun-version$'], | ||
versioning: id, | ||
}; | ||
|
||
export const categories: Category[] = ['js']; | ||
|
||
export function extractPackageFile(content: string): PackageFileContent | null { | ||
if (!content) { | ||
return null; | ||
} | ||
|
||
if (content.split('\n').length > 2) { | ||
return null; | ||
} | ||
|
||
const dep: PackageDependency = { | ||
depName: 'Bun', | ||
packageName: 'bun', | ||
currentValue: content.trim(), | ||
datasource: NpmDatasource.id, | ||
}; | ||
|
||
if (!isValid(content.trim())) { | ||
dep.skipReason = 'invalid-version'; | ||
} | ||
return { deps: [dep] }; | ||
} |
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 @@ | ||
Simply keeps the `.bun-version` file updated. |