Skip to content

Commit eff2bcb

Browse files
authored
Improve DependabotDependenciesSchema and make certain fields optional (#1610)
For some reason, the `DependabotDependenciesSchema` is used to parse when other types besides `update_dependency_list` and being processed. This PR makes the fields in the schema optional to cater to those till a solution comes up.
1 parent d394eb8 commit eff2bcb

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

extension/tasks/dependabotV2/dependabot/output-processor.ts

+20-17
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,26 @@ import { getBranchNameForUpdate } from './branch-name';
1010
import { IDependabotUpdateOperation } from './models';
1111

1212
export const DependabotDependenciesSchema = z.object({
13-
'dependencies': z.array(
14-
z.object({
15-
name: z.string(), // e.g. 'django' or 'GraphQL.Server.Ui.Voyager'
16-
requirements: z.array(
17-
z.object({
18-
file: z.string(), // e.g. 'requirements.txt' or '/Root.csproj'
19-
groups: z.array(z.string()), // e.g. ['dependencies']
20-
requirement: z.string(), // e.g. '==3.2.0' or '8.1.0'
21-
// others keys like 'source' are not clear on format/type
22-
}),
23-
),
24-
version: z.string(), // e.g. '5.0.1' or '8.1.0'
25-
}),
26-
),
27-
'dependency_files': z.array(z.string()), // e.g. ['/requirements.txt'] or ['/Root.csproj']
28-
// TODO: consider changing to date
29-
'last-updated': z.string().optional(), // e.g. '2021-09-01T00:00:00Z'
13+
dependencies: z
14+
.array(
15+
z.object({
16+
name: z.string(), // e.g. 'django' or 'GraphQL.Server.Ui.Voyager'
17+
requirements: z
18+
.array(
19+
z.object({
20+
file: z.string(), // e.g. 'requirements.txt' or '/Root.csproj'
21+
groups: z.array(z.string()).optional(), // e.g. ['dependencies']
22+
requirement: z.string().optional(), // e.g. '==3.2.0' or '8.1.0'
23+
// others keys like 'source' are not clear on format/type
24+
}),
25+
)
26+
.optional(),
27+
version: z.string().optional(), // e.g. '5.0.1' or '8.1.0'
28+
}),
29+
)
30+
.optional(),
31+
dependency_files: z.array(z.string()), // e.g. ['/requirements.txt'] or ['/Root.csproj']
32+
last_updated: z.date({ coerce: true }).optional(), // e.g. '2021-09-01T00:00:00Z'
3033
});
3134
export type DependabotDependencies = z.infer<typeof DependabotDependenciesSchema>;
3235

0 commit comments

Comments
 (0)