-
Notifications
You must be signed in to change notification settings - Fork 9
/
danger_dsl.dart
85 lines (61 loc) · 2.38 KB
/
danger_dsl.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import 'package:danger_core/src/models/bitbucket_cloud.dart';
import 'package:danger_core/src/models/git_dsl.dart';
import 'package:danger_core/src/models/github_dsl.dart';
import 'package:danger_core/src/models/gitlab_dsl.dart';
import 'package:danger_core/src/models/settings_github.dart';
import 'package:json_annotation/json_annotation.dart'
if (dart.library.isolate) 'package:danger_core/src/mock_json_annotation.dart';
part 'danger_dsl.g.dart';
class DangerJSONDSL {
/// The data only version of Git DSL
GitJSONDSL get git => rawJSONDSL.git;
/// The data only version of BitBucket Cloud DSL
BitBucketCloudJSONDSL get bitbucketCloud => rawJSONDSL.bitbucketCloud!;
/// The data only version of GitHub
GitHubDSL get github => rawJSONDSL.github!;
/// The data only version of GitLab
GitLabDSL get gitLab => rawJSONDSL.gitlab!;
DangerJSONSettings get settings => rawJSONDSL.settings!;
final DangerRawJSONDSL rawJSONDSL;
DangerJSONDSL(this.rawJSONDSL);
bool get isGitHub => rawJSONDSL.github != null;
bool get isBitbucketCloud => rawJSONDSL.bitbucketCloud != null;
bool get isGitLab => rawJSONDSL.gitlab != null;
}
@JsonSerializable()
class DangerJSON {
final DangerRawJSONDSL danger;
factory DangerJSON.fromJson(Map<String, dynamic> json) =>
_$DangerJSONFromJson(json);
DangerJSON({required this.danger});
Map<String, dynamic> toJson() => _$DangerJSONToJson(this);
}
@JsonSerializable()
class DangerRawJSONDSL {
/// The data only version of Git DSL
final GitJSONDSL git;
/// The data only version of BitBucket Cloud DSL
@JsonKey(name: 'bitbucket_cloud')
final BitBucketCloudJSONDSL? bitbucketCloud;
final GitHubDSL? github;
final GitLabDSL? gitlab;
final DangerJSONSettings? settings;
factory DangerRawJSONDSL.fromJson(Map<String, dynamic> json) =>
_$DangerRawJSONDSLFromJson(json);
DangerRawJSONDSL(
{required this.git,
this.bitbucketCloud,
this.github,
this.settings,
this.gitlab});
Map<String, dynamic> toJson() => _$DangerRawJSONDSLToJson(this);
}
@JsonSerializable()
class DangerJSONSettings {
final Map<String, dynamic>? cliArgs;
final DangetSettingsGithub? github;
factory DangerJSONSettings.fromJson(Map<String, dynamic> json) =>
_$DangerJSONSettingsFromJson(json);
DangerJSONSettings({this.cliArgs, this.github});
Map<String, dynamic> toJson() => _$DangerJSONSettingsToJson(this);
}