github-settings-as-code 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +54 -34
  2. package/dist/cmd/repo-settings.mjs +13 -0
  3. package/dist/cmd/repo-settings.mjs.map +1 -1
  4. package/dist/github/constants.d.mts +2 -0
  5. package/dist/github/constants.d.mts.map +1 -1
  6. package/dist/github/constants.mjs +2 -0
  7. package/dist/github/constants.mjs.map +1 -1
  8. package/dist/github/environments/api/get-environments.d.mts +16 -0
  9. package/dist/github/environments/api/get-environments.d.mts.map +1 -0
  10. package/dist/github/environments/api/get-environments.mjs +98 -0
  11. package/dist/github/environments/api/get-environments.mjs.map +1 -0
  12. package/dist/github/environments/api/index.d.mts +3 -0
  13. package/dist/github/environments/api/index.d.mts.map +1 -0
  14. package/dist/github/environments/api/index.mjs +3 -0
  15. package/dist/github/environments/api/index.mjs.map +1 -0
  16. package/dist/github/environments/api/set-environment.d.mts +10 -0
  17. package/dist/github/environments/api/set-environment.d.mts.map +1 -0
  18. package/dist/github/environments/api/set-environment.mjs +73 -0
  19. package/dist/github/environments/api/set-environment.mjs.map +1 -0
  20. package/dist/github/environments/apply.d.mts +11 -0
  21. package/dist/github/environments/apply.d.mts.map +1 -0
  22. package/dist/github/environments/apply.mjs +67 -0
  23. package/dist/github/environments/apply.mjs.map +1 -0
  24. package/dist/github/environments/backup.d.mts +5 -0
  25. package/dist/github/environments/backup.d.mts.map +1 -0
  26. package/dist/github/environments/backup.mjs +24 -0
  27. package/dist/github/environments/backup.mjs.map +1 -0
  28. package/dist/github/environments/constants.d.mts +354 -0
  29. package/dist/github/environments/constants.d.mts.map +1 -0
  30. package/dist/github/environments/constants.mjs +62 -0
  31. package/dist/github/environments/constants.mjs.map +1 -0
  32. package/dist/github/environments/index.d.mts +6 -0
  33. package/dist/github/environments/index.d.mts.map +1 -0
  34. package/dist/github/environments/index.mjs +6 -0
  35. package/dist/github/environments/index.mjs.map +1 -0
  36. package/dist/github/environments/read-environment-contents.d.mts +4 -0
  37. package/dist/github/environments/read-environment-contents.d.mts.map +1 -0
  38. package/dist/github/environments/read-environment-contents.mjs +32 -0
  39. package/dist/github/environments/read-environment-contents.mjs.map +1 -0
  40. package/dist/github/index.d.mts +2 -0
  41. package/dist/github/index.d.mts.map +1 -1
  42. package/dist/github/index.mjs +2 -0
  43. package/dist/github/index.mjs.map +1 -1
  44. package/dist/github/vulnerability-alerts/api/get-vulnerability-alerts.d.mts +10 -0
  45. package/dist/github/vulnerability-alerts/api/get-vulnerability-alerts.d.mts.map +1 -0
  46. package/dist/github/vulnerability-alerts/api/get-vulnerability-alerts.mjs +25 -0
  47. package/dist/github/vulnerability-alerts/api/get-vulnerability-alerts.mjs.map +1 -0
  48. package/dist/github/vulnerability-alerts/api/index.d.mts +3 -0
  49. package/dist/github/vulnerability-alerts/api/index.d.mts.map +1 -0
  50. package/dist/github/vulnerability-alerts/api/index.mjs +3 -0
  51. package/dist/github/vulnerability-alerts/api/index.mjs.map +1 -0
  52. package/dist/github/vulnerability-alerts/api/set-vulnerability-alerts.d.mts +10 -0
  53. package/dist/github/vulnerability-alerts/api/set-vulnerability-alerts.d.mts.map +1 -0
  54. package/dist/github/vulnerability-alerts/api/set-vulnerability-alerts.mjs +19 -0
  55. package/dist/github/vulnerability-alerts/api/set-vulnerability-alerts.mjs.map +1 -0
  56. package/dist/github/vulnerability-alerts/apply.d.mts +11 -0
  57. package/dist/github/vulnerability-alerts/apply.d.mts.map +1 -0
  58. package/dist/github/vulnerability-alerts/apply.mjs +47 -0
  59. package/dist/github/vulnerability-alerts/apply.mjs.map +1 -0
  60. package/dist/github/vulnerability-alerts/backup.d.mts +5 -0
  61. package/dist/github/vulnerability-alerts/backup.d.mts.map +1 -0
  62. package/dist/github/vulnerability-alerts/backup.mjs +22 -0
  63. package/dist/github/vulnerability-alerts/backup.mjs.map +1 -0
  64. package/dist/github/vulnerability-alerts/constants.d.mts +72 -0
  65. package/dist/github/vulnerability-alerts/constants.d.mts.map +1 -0
  66. package/dist/github/vulnerability-alerts/constants.mjs +21 -0
  67. package/dist/github/vulnerability-alerts/constants.mjs.map +1 -0
  68. package/dist/github/vulnerability-alerts/index.d.mts +5 -0
  69. package/dist/github/vulnerability-alerts/index.d.mts.map +1 -0
  70. package/dist/github/vulnerability-alerts/index.mjs +5 -0
  71. package/dist/github/vulnerability-alerts/index.mjs.map +1 -0
  72. package/package.json +1 -1
  73. package/src/cmd/repo-settings.mts +17 -0
  74. package/src/github/constants.mts +7 -0
  75. package/src/github/environments/api/get-environments.mts +155 -0
  76. package/src/github/environments/api/index.mts +2 -0
  77. package/src/github/environments/api/set-environment.mts +106 -0
  78. package/src/github/environments/apply.mts +87 -0
  79. package/src/github/environments/backup.mts +38 -0
  80. package/src/github/environments/constants.mts +78 -0
  81. package/src/github/environments/index.mts +5 -0
  82. package/src/github/environments/read-environment-contents.mts +53 -0
  83. package/src/github/index.mts +2 -0
  84. package/src/github/vulnerability-alerts/api/get-vulnerability-alerts.mts +31 -0
  85. package/src/github/vulnerability-alerts/api/index.mts +2 -0
  86. package/src/github/vulnerability-alerts/api/set-vulnerability-alerts.mts +31 -0
  87. package/src/github/vulnerability-alerts/apply.mts +77 -0
  88. package/src/github/vulnerability-alerts/backup.mts +36 -0
  89. package/src/github/vulnerability-alerts/constants.mts +25 -0
  90. package/src/github/vulnerability-alerts/index.mts +4 -0
@@ -0,0 +1,354 @@
1
+ import * as t from 'ts-fortress';
2
+ /**
3
+ * `repo-settings/environments/*.json` の型。
4
+ *
5
+ * Settings > Environments の 1 件に対応する。ファイルは「その環境の望ましい
6
+ * 状態」を丸ごと表しており、 GitHub 側で 2 つに分かれている次の API をまとめて
7
+ * 1 ファイルで管理する:
8
+ *
9
+ * - `PUT /repos/{owner}/{repo}/environments/{environment_name}`
10
+ * - `GET|POST|DELETE /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies`
11
+ *
12
+ * GET が返す `protection_rules` は「有効な保護ルールだけが並ぶ配列」だが、この
13
+ * 型は書き込み側( PUT の body )に合わせた平らな形にしている。往復させる側の
14
+ * 形を正とするほうが、ファイルを読んで何が起きるか分かりやすいため。
15
+ */
16
+ export declare const EnvironmentSettings: Readonly<{
17
+ typeName: string;
18
+ defaultValue: Readonly<{
19
+ deployment_branch_policies: readonly Readonly<{
20
+ name: string;
21
+ type: "branch" | "tag";
22
+ }>[];
23
+ deployment_branch_policy: Readonly<{
24
+ custom_branch_policies: boolean;
25
+ protected_branches: boolean;
26
+ }> | null;
27
+ name: string;
28
+ prevent_self_review: boolean;
29
+ reviewers: readonly Readonly<{
30
+ id: number;
31
+ type: "Team" | "User";
32
+ }>[];
33
+ wait_timer: number;
34
+ }>;
35
+ is: (a: unknown) => a is Readonly<{
36
+ deployment_branch_policies: readonly Readonly<{
37
+ name: string;
38
+ type: "branch" | "tag";
39
+ }>[];
40
+ deployment_branch_policy: Readonly<{
41
+ custom_branch_policies: boolean;
42
+ protected_branches: boolean;
43
+ }> | null;
44
+ name: string;
45
+ prevent_self_review: boolean;
46
+ reviewers: readonly Readonly<{
47
+ id: number;
48
+ type: "Team" | "User";
49
+ }>[];
50
+ wait_timer: number;
51
+ }>;
52
+ assertIs: (a: unknown) => asserts a is Readonly<{
53
+ deployment_branch_policies: readonly Readonly<{
54
+ name: string;
55
+ type: "branch" | "tag";
56
+ }>[];
57
+ deployment_branch_policy: Readonly<{
58
+ custom_branch_policies: boolean;
59
+ protected_branches: boolean;
60
+ }> | null;
61
+ name: string;
62
+ prevent_self_review: boolean;
63
+ reviewers: readonly Readonly<{
64
+ id: number;
65
+ type: "Team" | "User";
66
+ }>[];
67
+ wait_timer: number;
68
+ }>;
69
+ cast: (a: unknown) => Readonly<{
70
+ deployment_branch_policies: readonly Readonly<{
71
+ name: string;
72
+ type: "branch" | "tag";
73
+ }>[];
74
+ deployment_branch_policy: Readonly<{
75
+ custom_branch_policies: boolean;
76
+ protected_branches: boolean;
77
+ }> | null;
78
+ name: string;
79
+ prevent_self_review: boolean;
80
+ reviewers: readonly Readonly<{
81
+ id: number;
82
+ type: "Team" | "User";
83
+ }>[];
84
+ wait_timer: number;
85
+ }>;
86
+ fill: (a: unknown) => Readonly<{
87
+ deployment_branch_policies: readonly Readonly<{
88
+ name: string;
89
+ type: "branch" | "tag";
90
+ }>[];
91
+ deployment_branch_policy: Readonly<{
92
+ custom_branch_policies: boolean;
93
+ protected_branches: boolean;
94
+ }> | null;
95
+ name: string;
96
+ prevent_self_review: boolean;
97
+ reviewers: readonly Readonly<{
98
+ id: number;
99
+ type: "Team" | "User";
100
+ }>[];
101
+ wait_timer: number;
102
+ }>;
103
+ prune: <B extends Readonly<{
104
+ deployment_branch_policies: readonly Readonly<{
105
+ name: string;
106
+ type: "branch" | "tag";
107
+ }>[];
108
+ deployment_branch_policy: Readonly<{
109
+ custom_branch_policies: boolean;
110
+ protected_branches: boolean;
111
+ }> | null;
112
+ name: string;
113
+ prevent_self_review: boolean;
114
+ reviewers: readonly Readonly<{
115
+ id: number;
116
+ type: "Team" | "User";
117
+ }>[];
118
+ wait_timer: number;
119
+ }>>(a: B) => Readonly<{
120
+ deployment_branch_policies: readonly Readonly<{
121
+ name: string;
122
+ type: "branch" | "tag";
123
+ }>[];
124
+ deployment_branch_policy: Readonly<{
125
+ custom_branch_policies: boolean;
126
+ protected_branches: boolean;
127
+ }> | null;
128
+ name: string;
129
+ prevent_self_review: boolean;
130
+ reviewers: readonly Readonly<{
131
+ id: number;
132
+ type: "Team" | "User";
133
+ }>[];
134
+ wait_timer: number;
135
+ }>;
136
+ validate: (a: unknown) => t.Result<Readonly<{
137
+ deployment_branch_policies: readonly Readonly<{
138
+ name: string;
139
+ type: "branch" | "tag";
140
+ }>[];
141
+ deployment_branch_policy: Readonly<{
142
+ custom_branch_policies: boolean;
143
+ protected_branches: boolean;
144
+ }> | null;
145
+ name: string;
146
+ prevent_self_review: boolean;
147
+ reviewers: readonly Readonly<{
148
+ id: number;
149
+ type: "Team" | "User";
150
+ }>[];
151
+ wait_timer: number;
152
+ }>, readonly Readonly<{
153
+ path: readonly string[];
154
+ actualValue: unknown;
155
+ expectedType: string;
156
+ typeName: string;
157
+ details?: t.ValidationErrorDetails | undefined;
158
+ }>[]>;
159
+ optional?: true;
160
+ }> & Readonly<{
161
+ shape: {
162
+ readonly name: t.ConstrainedType<string, Readonly<{
163
+ readonly nonempty: undefined;
164
+ readonly minLength: undefined;
165
+ readonly maxLength: undefined;
166
+ readonly startsWith: undefined;
167
+ readonly endsWith: undefined;
168
+ readonly includes: undefined;
169
+ readonly uppercase: undefined;
170
+ readonly lowercase: undefined;
171
+ readonly regex: undefined;
172
+ }>>;
173
+ /** 「 Wait timer 」。分。 0 なら待たない。 */
174
+ readonly wait_timer: t.ConstrainedType<number, Readonly<{
175
+ readonly finite: undefined;
176
+ readonly int: undefined;
177
+ readonly safeInteger: undefined;
178
+ readonly nonZero: undefined;
179
+ readonly negative: undefined;
180
+ readonly nonNegative: undefined;
181
+ readonly positive: undefined;
182
+ readonly nonPositive: undefined;
183
+ readonly gt: undefined;
184
+ readonly gte: undefined;
185
+ readonly min: undefined;
186
+ readonly lt: undefined;
187
+ readonly lte: undefined;
188
+ readonly max: undefined;
189
+ readonly multipleOf: undefined;
190
+ readonly step: undefined;
191
+ }>>;
192
+ /** 「 Prevent self-review 」。 */
193
+ readonly prevent_self_review: Readonly<{
194
+ typeName: string;
195
+ defaultValue: boolean;
196
+ is: (a: unknown) => a is boolean;
197
+ assertIs: (a: unknown) => asserts a is boolean;
198
+ cast: (a: unknown) => boolean;
199
+ fill: (a: unknown) => boolean;
200
+ prune: <B extends boolean>(a: B) => boolean;
201
+ validate: (a: unknown) => t.Result<boolean, readonly Readonly<{
202
+ path: readonly string[];
203
+ actualValue: unknown;
204
+ expectedType: string;
205
+ typeName: string;
206
+ details?: t.ValidationErrorDetails | undefined;
207
+ }>[]>;
208
+ optional?: true;
209
+ }>;
210
+ /** 「 Required reviewers 」。空配列なら承認は要らない。 */
211
+ readonly reviewers: Readonly<{
212
+ typeName: string;
213
+ defaultValue: readonly Readonly<{
214
+ id: number;
215
+ type: "Team" | "User";
216
+ }>[];
217
+ is: (a: unknown) => a is readonly Readonly<{
218
+ id: number;
219
+ type: "Team" | "User";
220
+ }>[];
221
+ assertIs: (a: unknown) => asserts a is readonly Readonly<{
222
+ id: number;
223
+ type: "Team" | "User";
224
+ }>[];
225
+ cast: (a: unknown) => readonly Readonly<{
226
+ id: number;
227
+ type: "Team" | "User";
228
+ }>[];
229
+ fill: (a: unknown) => readonly Readonly<{
230
+ id: number;
231
+ type: "Team" | "User";
232
+ }>[];
233
+ prune: <B extends readonly Readonly<{
234
+ id: number;
235
+ type: "Team" | "User";
236
+ }>[]>(a: B) => readonly Readonly<{
237
+ id: number;
238
+ type: "Team" | "User";
239
+ }>[];
240
+ validate: (a: unknown) => t.Result<readonly Readonly<{
241
+ id: number;
242
+ type: "Team" | "User";
243
+ }>[], readonly Readonly<{
244
+ path: readonly string[];
245
+ actualValue: unknown;
246
+ expectedType: string;
247
+ typeName: string;
248
+ details?: t.ValidationErrorDetails | undefined;
249
+ }>[]>;
250
+ optional?: true;
251
+ }>;
252
+ /**
253
+ * 「 Deployment branches and tags 」の選択。
254
+ *
255
+ * - `null` … 「 No restriction 」( どの ref からでも deploy できる )
256
+ * - `protected_branches: true` … 「 Protected branches only 」
257
+ * - `custom_branch_policies: true` … 「 Selected branches and tags 」。
258
+ * 具体的な pattern は下の `deployment_branch_policies` 。
259
+ *
260
+ * 2 つを同時に `true` にはできない。
261
+ */
262
+ readonly deployment_branch_policy: Readonly<{
263
+ typeName: string;
264
+ defaultValue: Readonly<{
265
+ custom_branch_policies: boolean;
266
+ protected_branches: boolean;
267
+ }> | null;
268
+ is: (a: unknown) => a is Readonly<{
269
+ custom_branch_policies: boolean;
270
+ protected_branches: boolean;
271
+ }> | null;
272
+ assertIs: (a: unknown) => asserts a is Readonly<{
273
+ custom_branch_policies: boolean;
274
+ protected_branches: boolean;
275
+ }> | null;
276
+ cast: (a: unknown) => Readonly<{
277
+ custom_branch_policies: boolean;
278
+ protected_branches: boolean;
279
+ }> | null;
280
+ fill: (a: unknown) => Readonly<{
281
+ custom_branch_policies: boolean;
282
+ protected_branches: boolean;
283
+ }> | null;
284
+ prune: <B extends Readonly<{
285
+ custom_branch_policies: boolean;
286
+ protected_branches: boolean;
287
+ }> | null>(a: B) => Readonly<{
288
+ custom_branch_policies: boolean;
289
+ protected_branches: boolean;
290
+ }> | null;
291
+ validate: (a: unknown) => t.Result<Readonly<{
292
+ custom_branch_policies: boolean;
293
+ protected_branches: boolean;
294
+ }> | null, readonly Readonly<{
295
+ path: readonly string[];
296
+ actualValue: unknown;
297
+ expectedType: string;
298
+ typeName: string;
299
+ details?: t.ValidationErrorDetails | undefined;
300
+ }>[]>;
301
+ optional?: true;
302
+ }>;
303
+ /**
304
+ * `custom_branch_policies` が `true` のときの pattern 一覧。
305
+ *
306
+ * それ以外のときは空配列でなければならない ( `applyEnvironments` が拒否する )。
307
+ * GitHub 側は別エンドポイントだが、「どの ref から deploy できるか」を
308
+ * 決めているのは選択と pattern の組で、片方だけ見ても意味を成さない。
309
+ */
310
+ readonly deployment_branch_policies: Readonly<{
311
+ typeName: string;
312
+ defaultValue: readonly Readonly<{
313
+ name: string;
314
+ type: "branch" | "tag";
315
+ }>[];
316
+ is: (a: unknown) => a is readonly Readonly<{
317
+ name: string;
318
+ type: "branch" | "tag";
319
+ }>[];
320
+ assertIs: (a: unknown) => asserts a is readonly Readonly<{
321
+ name: string;
322
+ type: "branch" | "tag";
323
+ }>[];
324
+ cast: (a: unknown) => readonly Readonly<{
325
+ name: string;
326
+ type: "branch" | "tag";
327
+ }>[];
328
+ fill: (a: unknown) => readonly Readonly<{
329
+ name: string;
330
+ type: "branch" | "tag";
331
+ }>[];
332
+ prune: <B extends readonly Readonly<{
333
+ name: string;
334
+ type: "branch" | "tag";
335
+ }>[]>(a: B) => readonly Readonly<{
336
+ name: string;
337
+ type: "branch" | "tag";
338
+ }>[];
339
+ validate: (a: unknown) => t.Result<readonly Readonly<{
340
+ name: string;
341
+ type: "branch" | "tag";
342
+ }>[], readonly Readonly<{
343
+ path: readonly string[];
344
+ actualValue: unknown;
345
+ expectedType: string;
346
+ typeName: string;
347
+ details?: t.ValidationErrorDetails | undefined;
348
+ }>[]>;
349
+ optional?: true;
350
+ }>;
351
+ };
352
+ }>;
353
+ export type EnvironmentSettings = t.TypeOf<typeof EnvironmentSettings>;
354
+ //# sourceMappingURL=constants.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../../src/github/environments/constants.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AAEjC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAG9B,kCAAkC;;;;;;;;;;;;;;;;;;;QAGlC,+BAA+B;;;;;;;;;;;;;;;;;;QAG/B,2CAA2C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAY3C;;;;;;;;;WASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAYH;;;;;;WAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWH,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,62 @@
1
+ import * as t from 'ts-fortress';
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+ export const EnvironmentSettings = t.record({
17
+ name: t.string(''),
18
+
19
+ wait_timer: t.number(0),
20
+
21
+ prevent_self_review: t.boolean(false),
22
+
23
+ reviewers: t.array(t.record({
24
+ type: t.enumType(['User', 'Team'], {
25
+ typeName: 'EnvironmentReviewerType',
26
+ defaultValue: 'User',
27
+ }),
28
+ id: t.number(0),
29
+ }), { typeName: 'EnvironmentReviewers' }),
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+ deployment_branch_policy: t.union([
41
+ t.record({
42
+ protected_branches: t.boolean(false),
43
+ custom_branch_policies: t.boolean(true),
44
+ }),
45
+ t.nullType,
46
+ ], { typeName: 'DeploymentBranchPolicySelection' }),
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+ deployment_branch_policies: t.array(t.record({
55
+ name: t.string(''),
56
+ type: t.enumType(['branch', 'tag'], {
57
+ typeName: 'DeploymentBranchPolicyType',
58
+ defaultValue: 'branch',
59
+ }),
60
+ }), { typeName: 'DeploymentBranchPolicies' }),
61
+ });
62
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../../src/github/environments/constants.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AAEjC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IAElB,kCAAkC;IAClC,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAEvB,+BAA+B;IAC/B,mBAAmB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAErC,2CAA2C;IAC3C,SAAS,EAAE,CAAC,CAAC,KAAK,CAChB,CAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;YACjC,QAAQ,EAAE,yBAAyB;YACnC,YAAY,EAAE,MAAM;SACrB,CAAC;QACF,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;KAChB,CAAC,EACF,EAAE,QAAQ,EAAE,sBAAsB,EAAE,CACrC;IAED;;;;;;;;;OASG;IACH,wBAAwB,EAAE,CAAC,CAAC,KAAK,CAC/B;QACE,CAAC,CAAC,MAAM,CAAC;YACP,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;YACpC,sBAAsB,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;SACxC,CAAC;QACF,CAAC,CAAC,QAAQ;KACX,EACD,EAAE,QAAQ,EAAE,iCAAiC,EAAE,CAChD;IAED;;;;;;OAMG;IACH,0BAA0B,EAAE,CAAC,CAAC,KAAK,CACjC,CAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;QAClB,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE;YAClC,QAAQ,EAAE,4BAA4B;YACtC,YAAY,EAAE,QAAQ;SACvB,CAAC;KACH,CAAC,EACF,EAAE,QAAQ,EAAE,0BAA0B,EAAE,CACzC;CACF,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from './api/index.mjs';
2
+ export * from './apply.mjs';
3
+ export * from './backup.mjs';
4
+ export * from './constants.mjs';
5
+ export * from './read-environment-contents.mjs';
6
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/github/environments/index.mts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iCAAiC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from './api/index.mjs';
2
+ export * from './apply.mjs';
3
+ export * from './backup.mjs';
4
+ export * from './constants.mjs';
5
+ export * from './read-environment-contents.mjs';
6
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/github/environments/index.mts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iCAAiC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { EnvironmentSettings } from './constants.mjs';
2
+ export declare const readEnvironmentFiles: () => Promise<readonly EnvironmentSettings[]>;
3
+ export declare const readEnvironmentBackupFiles: () => Promise<readonly EnvironmentSettings[]>;
4
+ //# sourceMappingURL=read-environment-contents.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-environment-contents.d.mts","sourceRoot":"","sources":["../../../src/github/environments/read-environment-contents.mts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,eAAO,MAAM,oBAAoB,QAAa,OAAO,CACnD,SAAS,mBAAmB,EAAE,CACC,CAAC;AAElC,eAAO,MAAM,0BAA0B,QAAa,OAAO,CACzD,SAAS,mBAAmB,EAAE,CACuB,CAAC"}
@@ -0,0 +1,32 @@
1
+ import * as fs from 'node:fs/promises';
2
+ import * as path from 'node:path';
3
+ import * as t from 'ts-fortress';
4
+ import { isDirectlyExecuted, Result } from 'ts-repo-utils';
5
+ import { environmentsDir } from '../constants.mjs';
6
+ import { EnvironmentSettings } from './constants.mjs';
7
+ export const readEnvironmentFiles = async () => readFilesIn(environmentsDir);
8
+ export const readEnvironmentBackupFiles = async () => readFilesIn(path.resolve(environmentsDir, './bk'));
9
+ const readFilesIn = async (dir) => {
10
+
11
+ const files = await fs.readdir(dir, {
12
+ withFileTypes: true,
13
+ });
14
+ const fileContents = await Promise.all(files
15
+ .filter((d) => d.isFile())
16
+ .map((d) =>
17
+
18
+ fs.readFile(path.resolve(dir, d.name), { encoding: 'utf8' })));
19
+ const validationResults = fileContents.map((content) => EnvironmentSettings.validate(JSON.parse(content)));
20
+ const mut_values = [];
21
+ for (const r of validationResults) {
22
+ if (Result.isErr(r)) {
23
+ throw new Error(t.validationErrorsToMessages(r.value).join('\n'));
24
+ }
25
+ mut_values.push(r.value);
26
+ }
27
+ return mut_values;
28
+ };
29
+ if (isDirectlyExecuted(import.meta.url)) {
30
+ await readEnvironmentFiles();
31
+ }
32
+ //# sourceMappingURL=read-environment-contents.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-environment-contents.mjs","sourceRoot":"","sources":["../../../src/github/environments/read-environment-contents.mts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,IAEvC,EAAE,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;AAElC,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,IAE7C,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;AAExD,MAAM,WAAW,GAAG,KAAK,EACvB,GAAW,EAC8B,EAAE;IAC3C,mEAAmE;IACnE,MAAM,KAAK,GAA8B,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;QAC7D,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC;IAEH,MAAM,YAAY,GAAsB,MAAM,OAAO,CAAC,GAAG,CACvD,KAAK;SACF,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACzB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;IACT,mEAAmE;IACnE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAC7D,CACJ,CAAC;IAEF,MAAM,iBAAiB,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACrD,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAClD,CAAC;IAEF,MAAM,UAAU,GAA0B,EAAE,CAAC;IAE7C,KAAK,MAAM,CAAC,IAAI,iBAAiB,EAAE,CAAC;QAClC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACpE,CAAC;QAED,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,IAAI,kBAAkB,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACxC,MAAM,oBAAoB,EAAE,CAAC;AAC/B,CAAC"}
@@ -1,8 +1,10 @@
1
1
  export * from './actions-settings/index.mjs';
2
2
  export * from './constants.mjs';
3
+ export * from './environments/index.mjs';
3
4
  export * from './pages/index.mjs';
4
5
  export * from './repository/index.mjs';
5
6
  export * from './resolve-target-repo.mjs';
6
7
  export * from './ruleset/index.mjs';
7
8
  export * from './variables/index.mjs';
9
+ export * from './vulnerability-alerts/index.mjs';
8
10
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/github/index.mts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/github/index.mts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC"}
@@ -1,8 +1,10 @@
1
1
  export * from './actions-settings/index.mjs';
2
2
  export * from './constants.mjs';
3
+ export * from './environments/index.mjs';
3
4
  export * from './pages/index.mjs';
4
5
  export * from './repository/index.mjs';
5
6
  export * from './resolve-target-repo.mjs';
6
7
  export * from './ruleset/index.mjs';
7
8
  export * from './variables/index.mjs';
9
+ export * from './vulnerability-alerts/index.mjs';
8
10
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/github/index.mts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/github/index.mts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { VulnerabilityAlertsSettings } from '../constants.mjs';
2
+ /**
3
+ * Dependabot alerts が有効かどうかを取得する。
4
+ *
5
+ * このエンドポイントは body を返さない: 有効なら 204、無効なら 404。
6
+ * octokit は 404 を例外にするので、それを `enabled: false` として扱う。
7
+ * 「無効」と「読めなかった」は区別する必要があるため、 404 以外は投げ直す。
8
+ */
9
+ export declare const getVulnerabilityAlerts: () => Promise<VulnerabilityAlertsSettings>;
10
+ //# sourceMappingURL=get-vulnerability-alerts.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-vulnerability-alerts.d.mts","sourceRoot":"","sources":["../../../../src/github/vulnerability-alerts/api/get-vulnerability-alerts.mts"],"names":[],"mappings":"AAIA,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAE/D;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,QACvB,OAAO,CAAC,2BAA2B,CAgB5C,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { hasKey, isRecord } from 'ts-data-forge';
2
+ import { octokitHeaders, OWNER, REPO } from '../../constants.mjs';
3
+ import { octokit } from '../../octokit.mjs';
4
+ import { VulnerabilityAlertsSettings } from '../constants.mjs';
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ export const getVulnerabilityAlerts = async () => {
13
+ try {
14
+
15
+ await octokit.request('GET /repos/{owner}/{repo}/vulnerability-alerts', { owner: OWNER, repo: REPO, headers: octokitHeaders });
16
+ return VulnerabilityAlertsSettings.fill({ enabled: true });
17
+ }
18
+ catch (error) {
19
+ if (isRecord(error) && hasKey(error, 'status') && error.status === 404) {
20
+ return VulnerabilityAlertsSettings.fill({ enabled: false });
21
+ }
22
+ throw error;
23
+ }
24
+ };
25
+ //# sourceMappingURL=get-vulnerability-alerts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-vulnerability-alerts.mjs","sourceRoot":"","sources":["../../../../src/github/vulnerability-alerts/api/get-vulnerability-alerts.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GACjC,KAAK,IAA0C,EAAE;IAC/C,IAAI,CAAC;QACH,sGAAsG;QACtG,MAAM,OAAO,CAAC,OAAO,CACnB,gDAAuE,EACvE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE,CACtD,CAAC;QAEF,OAAO,2BAA2B,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACvE,OAAO,2BAA2B,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9D,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './get-vulnerability-alerts.mjs';
2
+ export * from './set-vulnerability-alerts.mjs';
3
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/github/vulnerability-alerts/api/index.mts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './get-vulnerability-alerts.mjs';
2
+ export * from './set-vulnerability-alerts.mjs';
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/github/vulnerability-alerts/api/index.mts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type VulnerabilityAlertsSettings } from '../constants.mjs';
2
+ /**
3
+ * Dependabot alerts を JSON の内容に合わせる。
4
+ *
5
+ * 有効化と無効化で別メソッドなので、書き込みは 1 回で済むように分岐する。
6
+ * `enabled: false` はきちんと無効化する — 宣言が現状に合わせて黙るなら、
7
+ * ファイルを読んでも何が有効なのか分からなくなる。
8
+ */
9
+ export declare const setVulnerabilityAlerts: (settings: VulnerabilityAlertsSettings) => Promise<void>;
10
+ //# sourceMappingURL=set-vulnerability-alerts.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-vulnerability-alerts.d.mts","sourceRoot":"","sources":["../../../../src/github/vulnerability-alerts/api/set-vulnerability-alerts.mts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAEpE;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,aACvB,2BAA2B,KACpC,OAAO,CAAC,IAAI,CAgBd,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { octokitHeaders, OWNER, REPO } from '../../constants.mjs';
2
+ import { octokit } from '../../octokit.mjs';
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ export const setVulnerabilityAlerts = async (settings) => {
11
+ if (settings.enabled) {
12
+
13
+ await octokit.request('PUT /repos/{owner}/{repo}/vulnerability-alerts', { owner: OWNER, repo: REPO, headers: octokitHeaders });
14
+ return;
15
+ }
16
+
17
+ await octokit.request('DELETE /repos/{owner}/{repo}/vulnerability-alerts', { owner: OWNER, repo: REPO, headers: octokitHeaders });
18
+ };
19
+ //# sourceMappingURL=set-vulnerability-alerts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-vulnerability-alerts.mjs","sourceRoot":"","sources":["../../../../src/github/vulnerability-alerts/api/set-vulnerability-alerts.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EACzC,QAAqC,EACtB,EAAE;IACjB,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,uEAAuE;QACvE,MAAM,OAAO,CAAC,OAAO,CACnB,gDAAuE,EACvE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE,CACtD,CAAC;QAEF,OAAO;IACT,CAAC;IAED,wEAAwE;IACxE,MAAM,OAAO,CAAC,OAAO,CACnB,mDAA0E,EAC1E,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE,CACtD,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ import 'dotenv/config';
3
+ /**
4
+ * `repo-settings/vulnerability-alerts/settings.json` を Dependabot alerts に反映する。
5
+ *
6
+ * 設定ファイルを置いていない repository では何もしない。 pages と同じ理由 —
7
+ * この package は他の repository からも使われるので、ファイルの不在を
8
+ * 「無効にせよ」と読むと、宣言していない設定を勝手に落としてしまう。
9
+ */
10
+ export declare const applyVulnerabilityAlerts: () => Promise<void>;
11
+ //# sourceMappingURL=apply.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply.d.mts","sourceRoot":"","sources":["../../../src/github/vulnerability-alerts/apply.mts"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAC;AAiBvB;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,QAAa,OAAO,CAAC,IAAI,CA4B7D,CAAC"}