Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion lib/config/presets/internal/custom-managers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ describe('config/presets/internal/custom-managers', () => {
describe('Update `tsconfig/node` version in tsconfig.json', () => {
const customManager = presets.tsconfigNodeVersions.customManagers?.[0];

it(`find dependencies in file`, async () => {
it(`find in tsconfig.json extends string`, async () => {
const fileContent = codeBlock`
{
"extends": "@tsconfig/node20/tsconfig.json",
Expand All @@ -833,6 +833,33 @@ describe('config/presets/internal/custom-managers', () => {
]);
});

it(`find in tsconfig.json extends array`, async () => {
const fileContent = codeBlock`
{
"extends": [
"@tsconfig/strictest/tsconfig.json",
"@tsconfig/node20/tsconfig.json"
],
"include": ["src/**/*"]
}
`;

const res = await extractPackageFile(
'regex',
fileContent,
'tsconfig.json',
customManager!,
);

expect(res?.deps).toMatchObject([
{
currentValue: '20',
datasource: 'npm',
depName: '@tsconfig/node20',
},
]);
});

describe('matches regexes patterns', () => {
it.each`
path | expected
Expand Down
5 changes: 2 additions & 3 deletions lib/config/presets/internal/custom-managers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,13 @@ export const presets: Record<string, Preset> = {
tsconfigNodeVersions: {
customManagers: [
{
autoReplaceStringTemplate:
'"extends": "@tsconfig/node{{{major}}}/tsconfig.json"',
autoReplaceStringTemplate: '"@tsconfig/node{{{major}}}/tsconfig.json"',
currentValueTemplate: '{{{major}}}',
customType: 'regex',
datasourceTemplate: 'npm',
managerFilePatterns: ['**/tsconfig.json'],
matchStrings: [
'"extends":\\s*"(?<depName>@tsconfig/node(?<major>\\d+))/tsconfig\\.json"',
'"(?<depName>@tsconfig/node(?<major>\\d+))/tsconfig\\.json"',
],
},
],
Expand Down