@0xbigboss/gh-pulse-core 1.0.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.
- package/dist/cache.cjs +312 -0
- package/dist/cache.d.cts +58 -0
- package/dist/cache.d.ts +58 -0
- package/dist/cache.js +303 -0
- package/dist/config.cjs +182 -0
- package/dist/config.d.cts +248 -0
- package/dist/config.d.ts +248 -0
- package/dist/config.js +172 -0
- package/dist/filters.cjs +16 -0
- package/dist/filters.d.cts +3 -0
- package/dist/filters.d.ts +3 -0
- package/dist/filters.js +12 -0
- package/dist/github.cjs +240 -0
- package/dist/github.d.cts +46 -0
- package/dist/github.d.ts +46 -0
- package/dist/github.js +235 -0
- package/dist/index.cjs +28 -0
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +11 -0
- package/dist/reports/context.cjs +8 -0
- package/dist/reports/context.d.cts +7 -0
- package/dist/reports/context.d.ts +7 -0
- package/dist/reports/context.js +5 -0
- package/dist/reports/exec.cjs +160 -0
- package/dist/reports/exec.d.cts +6 -0
- package/dist/reports/exec.d.ts +6 -0
- package/dist/reports/exec.js +157 -0
- package/dist/reports/index.cjs +21 -0
- package/dist/reports/index.d.cts +5 -0
- package/dist/reports/index.d.ts +5 -0
- package/dist/reports/index.js +5 -0
- package/dist/reports/meta.cjs +15 -0
- package/dist/reports/meta.d.cts +12 -0
- package/dist/reports/meta.d.ts +12 -0
- package/dist/reports/meta.js +12 -0
- package/dist/reports/personal.cjs +90 -0
- package/dist/reports/personal.d.cts +8 -0
- package/dist/reports/personal.d.ts +8 -0
- package/dist/reports/personal.js +87 -0
- package/dist/reports/team.cjs +127 -0
- package/dist/reports/team.d.cts +6 -0
- package/dist/reports/team.d.ts +6 -0
- package/dist/reports/team.js +124 -0
- package/dist/reports/types.cjs +2 -0
- package/dist/reports/types.d.cts +144 -0
- package/dist/reports/types.d.ts +144 -0
- package/dist/reports/types.js +1 -0
- package/dist/reports/utils.cjs +71 -0
- package/dist/reports/utils.d.cts +6 -0
- package/dist/reports/utils.d.ts +6 -0
- package/dist/reports/utils.js +65 -0
- package/dist/repos.cjs +102 -0
- package/dist/repos.d.cts +12 -0
- package/dist/repos.d.ts +12 -0
- package/dist/repos.js +96 -0
- package/dist/sync.cjs +360 -0
- package/dist/sync.d.cts +24 -0
- package/dist/sync.d.ts +24 -0
- package/dist/sync.js +357 -0
- package/dist/team.cjs +45 -0
- package/dist/team.d.cts +10 -0
- package/dist/team.d.ts +10 -0
- package/dist/team.js +42 -0
- package/dist/time.cjs +153 -0
- package/dist/time.d.cts +13 -0
- package/dist/time.d.ts +13 -0
- package/dist/time.js +145 -0
- package/dist/types.cjs +2 -0
- package/dist/types.d.cts +133 -0
- package/dist/types.d.ts +133 -0
- package/dist/types.js +1 -0
- package/package.json +29 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const ResolvedConfigSchema: z.ZodObject<{
|
|
3
|
+
linear_api_key: z.ZodOptional<z.ZodString>;
|
|
4
|
+
orgs: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
5
|
+
repos: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
6
|
+
team: z.ZodDefault<z.ZodObject<{
|
|
7
|
+
strategy: z.ZodDefault<z.ZodEnum<["org_members", "config_list", "repo_contributors"]>>;
|
|
8
|
+
members: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
strategy: "org_members" | "config_list" | "repo_contributors";
|
|
11
|
+
members: string[];
|
|
12
|
+
}, {
|
|
13
|
+
strategy?: "org_members" | "config_list" | "repo_contributors" | undefined;
|
|
14
|
+
members?: string[] | undefined;
|
|
15
|
+
}>>;
|
|
16
|
+
exclude: z.ZodDefault<z.ZodObject<{
|
|
17
|
+
bots: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
+
forks: z.ZodDefault<z.ZodBoolean>;
|
|
19
|
+
archived: z.ZodDefault<z.ZodBoolean>;
|
|
20
|
+
authors: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
bots: boolean;
|
|
23
|
+
forks: boolean;
|
|
24
|
+
archived: boolean;
|
|
25
|
+
authors: string[];
|
|
26
|
+
}, {
|
|
27
|
+
bots?: boolean | undefined;
|
|
28
|
+
forks?: boolean | undefined;
|
|
29
|
+
archived?: boolean | undefined;
|
|
30
|
+
authors?: string[] | undefined;
|
|
31
|
+
}>>;
|
|
32
|
+
thresholds: z.ZodDefault<z.ZodObject<{
|
|
33
|
+
stale_days: z.ZodDefault<z.ZodNumber>;
|
|
34
|
+
stuck_days: z.ZodDefault<z.ZodNumber>;
|
|
35
|
+
large_pr_lines: z.ZodDefault<z.ZodNumber>;
|
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
|
37
|
+
stale_days: number;
|
|
38
|
+
stuck_days: number;
|
|
39
|
+
large_pr_lines: number;
|
|
40
|
+
}, {
|
|
41
|
+
stale_days?: number | undefined;
|
|
42
|
+
stuck_days?: number | undefined;
|
|
43
|
+
large_pr_lines?: number | undefined;
|
|
44
|
+
}>>;
|
|
45
|
+
timezone: z.ZodDefault<z.ZodString>;
|
|
46
|
+
cache: z.ZodDefault<z.ZodObject<{
|
|
47
|
+
path: z.ZodDefault<z.ZodString>;
|
|
48
|
+
ttl_hours: z.ZodDefault<z.ZodNumber>;
|
|
49
|
+
sync_ttl_hours: z.ZodDefault<z.ZodNumber>;
|
|
50
|
+
concurrency: z.ZodDefault<z.ZodNumber>;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
path: string;
|
|
53
|
+
ttl_hours: number;
|
|
54
|
+
sync_ttl_hours: number;
|
|
55
|
+
concurrency: number;
|
|
56
|
+
}, {
|
|
57
|
+
path?: string | undefined;
|
|
58
|
+
ttl_hours?: number | undefined;
|
|
59
|
+
sync_ttl_hours?: number | undefined;
|
|
60
|
+
concurrency?: number | undefined;
|
|
61
|
+
}>>;
|
|
62
|
+
} & {
|
|
63
|
+
github_token: z.ZodString;
|
|
64
|
+
}, "strip", z.ZodTypeAny, {
|
|
65
|
+
github_token: string;
|
|
66
|
+
orgs: string[];
|
|
67
|
+
repos: string[];
|
|
68
|
+
team: {
|
|
69
|
+
strategy: "org_members" | "config_list" | "repo_contributors";
|
|
70
|
+
members: string[];
|
|
71
|
+
};
|
|
72
|
+
exclude: {
|
|
73
|
+
bots: boolean;
|
|
74
|
+
forks: boolean;
|
|
75
|
+
archived: boolean;
|
|
76
|
+
authors: string[];
|
|
77
|
+
};
|
|
78
|
+
thresholds: {
|
|
79
|
+
stale_days: number;
|
|
80
|
+
stuck_days: number;
|
|
81
|
+
large_pr_lines: number;
|
|
82
|
+
};
|
|
83
|
+
timezone: string;
|
|
84
|
+
cache: {
|
|
85
|
+
path: string;
|
|
86
|
+
ttl_hours: number;
|
|
87
|
+
sync_ttl_hours: number;
|
|
88
|
+
concurrency: number;
|
|
89
|
+
};
|
|
90
|
+
linear_api_key?: string | undefined;
|
|
91
|
+
}, {
|
|
92
|
+
github_token: string;
|
|
93
|
+
linear_api_key?: string | undefined;
|
|
94
|
+
orgs?: string[] | undefined;
|
|
95
|
+
repos?: string[] | undefined;
|
|
96
|
+
team?: {
|
|
97
|
+
strategy?: "org_members" | "config_list" | "repo_contributors" | undefined;
|
|
98
|
+
members?: string[] | undefined;
|
|
99
|
+
} | undefined;
|
|
100
|
+
exclude?: {
|
|
101
|
+
bots?: boolean | undefined;
|
|
102
|
+
forks?: boolean | undefined;
|
|
103
|
+
archived?: boolean | undefined;
|
|
104
|
+
authors?: string[] | undefined;
|
|
105
|
+
} | undefined;
|
|
106
|
+
thresholds?: {
|
|
107
|
+
stale_days?: number | undefined;
|
|
108
|
+
stuck_days?: number | undefined;
|
|
109
|
+
large_pr_lines?: number | undefined;
|
|
110
|
+
} | undefined;
|
|
111
|
+
timezone?: string | undefined;
|
|
112
|
+
cache?: {
|
|
113
|
+
path?: string | undefined;
|
|
114
|
+
ttl_hours?: number | undefined;
|
|
115
|
+
sync_ttl_hours?: number | undefined;
|
|
116
|
+
concurrency?: number | undefined;
|
|
117
|
+
} | undefined;
|
|
118
|
+
}>;
|
|
119
|
+
export type Config = z.infer<typeof ResolvedConfigSchema>;
|
|
120
|
+
export declare const DEFAULT_CONFIG_ENV = "GH_PULSE_CONFIG";
|
|
121
|
+
/**
|
|
122
|
+
* Try to get GitHub token from `gh` CLI.
|
|
123
|
+
* Returns undefined if gh is not available or not authenticated.
|
|
124
|
+
*/
|
|
125
|
+
export declare function getGhCliToken(): string | undefined;
|
|
126
|
+
export declare function resolveConfigPath(providedPath?: string, env?: NodeJS.ProcessEnv): string;
|
|
127
|
+
export declare function resolveCachePath(configuredPath: string | undefined, env?: NodeJS.ProcessEnv): string;
|
|
128
|
+
export declare function loadConfig(options?: {
|
|
129
|
+
path?: string;
|
|
130
|
+
env?: NodeJS.ProcessEnv;
|
|
131
|
+
}): Promise<Config>;
|
|
132
|
+
export declare const CONFIG_SCHEMA: z.ZodObject<{
|
|
133
|
+
github_token: z.ZodOptional<z.ZodString>;
|
|
134
|
+
linear_api_key: z.ZodOptional<z.ZodString>;
|
|
135
|
+
orgs: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
136
|
+
repos: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
137
|
+
team: z.ZodDefault<z.ZodObject<{
|
|
138
|
+
strategy: z.ZodDefault<z.ZodEnum<["org_members", "config_list", "repo_contributors"]>>;
|
|
139
|
+
members: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
140
|
+
}, "strip", z.ZodTypeAny, {
|
|
141
|
+
strategy: "org_members" | "config_list" | "repo_contributors";
|
|
142
|
+
members: string[];
|
|
143
|
+
}, {
|
|
144
|
+
strategy?: "org_members" | "config_list" | "repo_contributors" | undefined;
|
|
145
|
+
members?: string[] | undefined;
|
|
146
|
+
}>>;
|
|
147
|
+
exclude: z.ZodDefault<z.ZodObject<{
|
|
148
|
+
bots: z.ZodDefault<z.ZodBoolean>;
|
|
149
|
+
forks: z.ZodDefault<z.ZodBoolean>;
|
|
150
|
+
archived: z.ZodDefault<z.ZodBoolean>;
|
|
151
|
+
authors: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
152
|
+
}, "strip", z.ZodTypeAny, {
|
|
153
|
+
bots: boolean;
|
|
154
|
+
forks: boolean;
|
|
155
|
+
archived: boolean;
|
|
156
|
+
authors: string[];
|
|
157
|
+
}, {
|
|
158
|
+
bots?: boolean | undefined;
|
|
159
|
+
forks?: boolean | undefined;
|
|
160
|
+
archived?: boolean | undefined;
|
|
161
|
+
authors?: string[] | undefined;
|
|
162
|
+
}>>;
|
|
163
|
+
thresholds: z.ZodDefault<z.ZodObject<{
|
|
164
|
+
stale_days: z.ZodDefault<z.ZodNumber>;
|
|
165
|
+
stuck_days: z.ZodDefault<z.ZodNumber>;
|
|
166
|
+
large_pr_lines: z.ZodDefault<z.ZodNumber>;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
stale_days: number;
|
|
169
|
+
stuck_days: number;
|
|
170
|
+
large_pr_lines: number;
|
|
171
|
+
}, {
|
|
172
|
+
stale_days?: number | undefined;
|
|
173
|
+
stuck_days?: number | undefined;
|
|
174
|
+
large_pr_lines?: number | undefined;
|
|
175
|
+
}>>;
|
|
176
|
+
timezone: z.ZodDefault<z.ZodString>;
|
|
177
|
+
cache: z.ZodDefault<z.ZodObject<{
|
|
178
|
+
path: z.ZodDefault<z.ZodString>;
|
|
179
|
+
ttl_hours: z.ZodDefault<z.ZodNumber>;
|
|
180
|
+
sync_ttl_hours: z.ZodDefault<z.ZodNumber>;
|
|
181
|
+
concurrency: z.ZodDefault<z.ZodNumber>;
|
|
182
|
+
}, "strip", z.ZodTypeAny, {
|
|
183
|
+
path: string;
|
|
184
|
+
ttl_hours: number;
|
|
185
|
+
sync_ttl_hours: number;
|
|
186
|
+
concurrency: number;
|
|
187
|
+
}, {
|
|
188
|
+
path?: string | undefined;
|
|
189
|
+
ttl_hours?: number | undefined;
|
|
190
|
+
sync_ttl_hours?: number | undefined;
|
|
191
|
+
concurrency?: number | undefined;
|
|
192
|
+
}>>;
|
|
193
|
+
}, "strip", z.ZodTypeAny, {
|
|
194
|
+
orgs: string[];
|
|
195
|
+
repos: string[];
|
|
196
|
+
team: {
|
|
197
|
+
strategy: "org_members" | "config_list" | "repo_contributors";
|
|
198
|
+
members: string[];
|
|
199
|
+
};
|
|
200
|
+
exclude: {
|
|
201
|
+
bots: boolean;
|
|
202
|
+
forks: boolean;
|
|
203
|
+
archived: boolean;
|
|
204
|
+
authors: string[];
|
|
205
|
+
};
|
|
206
|
+
thresholds: {
|
|
207
|
+
stale_days: number;
|
|
208
|
+
stuck_days: number;
|
|
209
|
+
large_pr_lines: number;
|
|
210
|
+
};
|
|
211
|
+
timezone: string;
|
|
212
|
+
cache: {
|
|
213
|
+
path: string;
|
|
214
|
+
ttl_hours: number;
|
|
215
|
+
sync_ttl_hours: number;
|
|
216
|
+
concurrency: number;
|
|
217
|
+
};
|
|
218
|
+
github_token?: string | undefined;
|
|
219
|
+
linear_api_key?: string | undefined;
|
|
220
|
+
}, {
|
|
221
|
+
github_token?: string | undefined;
|
|
222
|
+
linear_api_key?: string | undefined;
|
|
223
|
+
orgs?: string[] | undefined;
|
|
224
|
+
repos?: string[] | undefined;
|
|
225
|
+
team?: {
|
|
226
|
+
strategy?: "org_members" | "config_list" | "repo_contributors" | undefined;
|
|
227
|
+
members?: string[] | undefined;
|
|
228
|
+
} | undefined;
|
|
229
|
+
exclude?: {
|
|
230
|
+
bots?: boolean | undefined;
|
|
231
|
+
forks?: boolean | undefined;
|
|
232
|
+
archived?: boolean | undefined;
|
|
233
|
+
authors?: string[] | undefined;
|
|
234
|
+
} | undefined;
|
|
235
|
+
thresholds?: {
|
|
236
|
+
stale_days?: number | undefined;
|
|
237
|
+
stuck_days?: number | undefined;
|
|
238
|
+
large_pr_lines?: number | undefined;
|
|
239
|
+
} | undefined;
|
|
240
|
+
timezone?: string | undefined;
|
|
241
|
+
cache?: {
|
|
242
|
+
path?: string | undefined;
|
|
243
|
+
ttl_hours?: number | undefined;
|
|
244
|
+
sync_ttl_hours?: number | undefined;
|
|
245
|
+
concurrency?: number | undefined;
|
|
246
|
+
} | undefined;
|
|
247
|
+
}>;
|
|
248
|
+
export {};
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const ResolvedConfigSchema: z.ZodObject<{
|
|
3
|
+
linear_api_key: z.ZodOptional<z.ZodString>;
|
|
4
|
+
orgs: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
5
|
+
repos: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
6
|
+
team: z.ZodDefault<z.ZodObject<{
|
|
7
|
+
strategy: z.ZodDefault<z.ZodEnum<["org_members", "config_list", "repo_contributors"]>>;
|
|
8
|
+
members: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
strategy: "org_members" | "config_list" | "repo_contributors";
|
|
11
|
+
members: string[];
|
|
12
|
+
}, {
|
|
13
|
+
strategy?: "org_members" | "config_list" | "repo_contributors" | undefined;
|
|
14
|
+
members?: string[] | undefined;
|
|
15
|
+
}>>;
|
|
16
|
+
exclude: z.ZodDefault<z.ZodObject<{
|
|
17
|
+
bots: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
+
forks: z.ZodDefault<z.ZodBoolean>;
|
|
19
|
+
archived: z.ZodDefault<z.ZodBoolean>;
|
|
20
|
+
authors: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
bots: boolean;
|
|
23
|
+
forks: boolean;
|
|
24
|
+
archived: boolean;
|
|
25
|
+
authors: string[];
|
|
26
|
+
}, {
|
|
27
|
+
bots?: boolean | undefined;
|
|
28
|
+
forks?: boolean | undefined;
|
|
29
|
+
archived?: boolean | undefined;
|
|
30
|
+
authors?: string[] | undefined;
|
|
31
|
+
}>>;
|
|
32
|
+
thresholds: z.ZodDefault<z.ZodObject<{
|
|
33
|
+
stale_days: z.ZodDefault<z.ZodNumber>;
|
|
34
|
+
stuck_days: z.ZodDefault<z.ZodNumber>;
|
|
35
|
+
large_pr_lines: z.ZodDefault<z.ZodNumber>;
|
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
|
37
|
+
stale_days: number;
|
|
38
|
+
stuck_days: number;
|
|
39
|
+
large_pr_lines: number;
|
|
40
|
+
}, {
|
|
41
|
+
stale_days?: number | undefined;
|
|
42
|
+
stuck_days?: number | undefined;
|
|
43
|
+
large_pr_lines?: number | undefined;
|
|
44
|
+
}>>;
|
|
45
|
+
timezone: z.ZodDefault<z.ZodString>;
|
|
46
|
+
cache: z.ZodDefault<z.ZodObject<{
|
|
47
|
+
path: z.ZodDefault<z.ZodString>;
|
|
48
|
+
ttl_hours: z.ZodDefault<z.ZodNumber>;
|
|
49
|
+
sync_ttl_hours: z.ZodDefault<z.ZodNumber>;
|
|
50
|
+
concurrency: z.ZodDefault<z.ZodNumber>;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
path: string;
|
|
53
|
+
ttl_hours: number;
|
|
54
|
+
sync_ttl_hours: number;
|
|
55
|
+
concurrency: number;
|
|
56
|
+
}, {
|
|
57
|
+
path?: string | undefined;
|
|
58
|
+
ttl_hours?: number | undefined;
|
|
59
|
+
sync_ttl_hours?: number | undefined;
|
|
60
|
+
concurrency?: number | undefined;
|
|
61
|
+
}>>;
|
|
62
|
+
} & {
|
|
63
|
+
github_token: z.ZodString;
|
|
64
|
+
}, "strip", z.ZodTypeAny, {
|
|
65
|
+
github_token: string;
|
|
66
|
+
orgs: string[];
|
|
67
|
+
repos: string[];
|
|
68
|
+
team: {
|
|
69
|
+
strategy: "org_members" | "config_list" | "repo_contributors";
|
|
70
|
+
members: string[];
|
|
71
|
+
};
|
|
72
|
+
exclude: {
|
|
73
|
+
bots: boolean;
|
|
74
|
+
forks: boolean;
|
|
75
|
+
archived: boolean;
|
|
76
|
+
authors: string[];
|
|
77
|
+
};
|
|
78
|
+
thresholds: {
|
|
79
|
+
stale_days: number;
|
|
80
|
+
stuck_days: number;
|
|
81
|
+
large_pr_lines: number;
|
|
82
|
+
};
|
|
83
|
+
timezone: string;
|
|
84
|
+
cache: {
|
|
85
|
+
path: string;
|
|
86
|
+
ttl_hours: number;
|
|
87
|
+
sync_ttl_hours: number;
|
|
88
|
+
concurrency: number;
|
|
89
|
+
};
|
|
90
|
+
linear_api_key?: string | undefined;
|
|
91
|
+
}, {
|
|
92
|
+
github_token: string;
|
|
93
|
+
linear_api_key?: string | undefined;
|
|
94
|
+
orgs?: string[] | undefined;
|
|
95
|
+
repos?: string[] | undefined;
|
|
96
|
+
team?: {
|
|
97
|
+
strategy?: "org_members" | "config_list" | "repo_contributors" | undefined;
|
|
98
|
+
members?: string[] | undefined;
|
|
99
|
+
} | undefined;
|
|
100
|
+
exclude?: {
|
|
101
|
+
bots?: boolean | undefined;
|
|
102
|
+
forks?: boolean | undefined;
|
|
103
|
+
archived?: boolean | undefined;
|
|
104
|
+
authors?: string[] | undefined;
|
|
105
|
+
} | undefined;
|
|
106
|
+
thresholds?: {
|
|
107
|
+
stale_days?: number | undefined;
|
|
108
|
+
stuck_days?: number | undefined;
|
|
109
|
+
large_pr_lines?: number | undefined;
|
|
110
|
+
} | undefined;
|
|
111
|
+
timezone?: string | undefined;
|
|
112
|
+
cache?: {
|
|
113
|
+
path?: string | undefined;
|
|
114
|
+
ttl_hours?: number | undefined;
|
|
115
|
+
sync_ttl_hours?: number | undefined;
|
|
116
|
+
concurrency?: number | undefined;
|
|
117
|
+
} | undefined;
|
|
118
|
+
}>;
|
|
119
|
+
export type Config = z.infer<typeof ResolvedConfigSchema>;
|
|
120
|
+
export declare const DEFAULT_CONFIG_ENV = "GH_PULSE_CONFIG";
|
|
121
|
+
/**
|
|
122
|
+
* Try to get GitHub token from `gh` CLI.
|
|
123
|
+
* Returns undefined if gh is not available or not authenticated.
|
|
124
|
+
*/
|
|
125
|
+
export declare function getGhCliToken(): string | undefined;
|
|
126
|
+
export declare function resolveConfigPath(providedPath?: string, env?: NodeJS.ProcessEnv): string;
|
|
127
|
+
export declare function resolveCachePath(configuredPath: string | undefined, env?: NodeJS.ProcessEnv): string;
|
|
128
|
+
export declare function loadConfig(options?: {
|
|
129
|
+
path?: string;
|
|
130
|
+
env?: NodeJS.ProcessEnv;
|
|
131
|
+
}): Promise<Config>;
|
|
132
|
+
export declare const CONFIG_SCHEMA: z.ZodObject<{
|
|
133
|
+
github_token: z.ZodOptional<z.ZodString>;
|
|
134
|
+
linear_api_key: z.ZodOptional<z.ZodString>;
|
|
135
|
+
orgs: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
136
|
+
repos: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
137
|
+
team: z.ZodDefault<z.ZodObject<{
|
|
138
|
+
strategy: z.ZodDefault<z.ZodEnum<["org_members", "config_list", "repo_contributors"]>>;
|
|
139
|
+
members: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
140
|
+
}, "strip", z.ZodTypeAny, {
|
|
141
|
+
strategy: "org_members" | "config_list" | "repo_contributors";
|
|
142
|
+
members: string[];
|
|
143
|
+
}, {
|
|
144
|
+
strategy?: "org_members" | "config_list" | "repo_contributors" | undefined;
|
|
145
|
+
members?: string[] | undefined;
|
|
146
|
+
}>>;
|
|
147
|
+
exclude: z.ZodDefault<z.ZodObject<{
|
|
148
|
+
bots: z.ZodDefault<z.ZodBoolean>;
|
|
149
|
+
forks: z.ZodDefault<z.ZodBoolean>;
|
|
150
|
+
archived: z.ZodDefault<z.ZodBoolean>;
|
|
151
|
+
authors: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
152
|
+
}, "strip", z.ZodTypeAny, {
|
|
153
|
+
bots: boolean;
|
|
154
|
+
forks: boolean;
|
|
155
|
+
archived: boolean;
|
|
156
|
+
authors: string[];
|
|
157
|
+
}, {
|
|
158
|
+
bots?: boolean | undefined;
|
|
159
|
+
forks?: boolean | undefined;
|
|
160
|
+
archived?: boolean | undefined;
|
|
161
|
+
authors?: string[] | undefined;
|
|
162
|
+
}>>;
|
|
163
|
+
thresholds: z.ZodDefault<z.ZodObject<{
|
|
164
|
+
stale_days: z.ZodDefault<z.ZodNumber>;
|
|
165
|
+
stuck_days: z.ZodDefault<z.ZodNumber>;
|
|
166
|
+
large_pr_lines: z.ZodDefault<z.ZodNumber>;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
stale_days: number;
|
|
169
|
+
stuck_days: number;
|
|
170
|
+
large_pr_lines: number;
|
|
171
|
+
}, {
|
|
172
|
+
stale_days?: number | undefined;
|
|
173
|
+
stuck_days?: number | undefined;
|
|
174
|
+
large_pr_lines?: number | undefined;
|
|
175
|
+
}>>;
|
|
176
|
+
timezone: z.ZodDefault<z.ZodString>;
|
|
177
|
+
cache: z.ZodDefault<z.ZodObject<{
|
|
178
|
+
path: z.ZodDefault<z.ZodString>;
|
|
179
|
+
ttl_hours: z.ZodDefault<z.ZodNumber>;
|
|
180
|
+
sync_ttl_hours: z.ZodDefault<z.ZodNumber>;
|
|
181
|
+
concurrency: z.ZodDefault<z.ZodNumber>;
|
|
182
|
+
}, "strip", z.ZodTypeAny, {
|
|
183
|
+
path: string;
|
|
184
|
+
ttl_hours: number;
|
|
185
|
+
sync_ttl_hours: number;
|
|
186
|
+
concurrency: number;
|
|
187
|
+
}, {
|
|
188
|
+
path?: string | undefined;
|
|
189
|
+
ttl_hours?: number | undefined;
|
|
190
|
+
sync_ttl_hours?: number | undefined;
|
|
191
|
+
concurrency?: number | undefined;
|
|
192
|
+
}>>;
|
|
193
|
+
}, "strip", z.ZodTypeAny, {
|
|
194
|
+
orgs: string[];
|
|
195
|
+
repos: string[];
|
|
196
|
+
team: {
|
|
197
|
+
strategy: "org_members" | "config_list" | "repo_contributors";
|
|
198
|
+
members: string[];
|
|
199
|
+
};
|
|
200
|
+
exclude: {
|
|
201
|
+
bots: boolean;
|
|
202
|
+
forks: boolean;
|
|
203
|
+
archived: boolean;
|
|
204
|
+
authors: string[];
|
|
205
|
+
};
|
|
206
|
+
thresholds: {
|
|
207
|
+
stale_days: number;
|
|
208
|
+
stuck_days: number;
|
|
209
|
+
large_pr_lines: number;
|
|
210
|
+
};
|
|
211
|
+
timezone: string;
|
|
212
|
+
cache: {
|
|
213
|
+
path: string;
|
|
214
|
+
ttl_hours: number;
|
|
215
|
+
sync_ttl_hours: number;
|
|
216
|
+
concurrency: number;
|
|
217
|
+
};
|
|
218
|
+
github_token?: string | undefined;
|
|
219
|
+
linear_api_key?: string | undefined;
|
|
220
|
+
}, {
|
|
221
|
+
github_token?: string | undefined;
|
|
222
|
+
linear_api_key?: string | undefined;
|
|
223
|
+
orgs?: string[] | undefined;
|
|
224
|
+
repos?: string[] | undefined;
|
|
225
|
+
team?: {
|
|
226
|
+
strategy?: "org_members" | "config_list" | "repo_contributors" | undefined;
|
|
227
|
+
members?: string[] | undefined;
|
|
228
|
+
} | undefined;
|
|
229
|
+
exclude?: {
|
|
230
|
+
bots?: boolean | undefined;
|
|
231
|
+
forks?: boolean | undefined;
|
|
232
|
+
archived?: boolean | undefined;
|
|
233
|
+
authors?: string[] | undefined;
|
|
234
|
+
} | undefined;
|
|
235
|
+
thresholds?: {
|
|
236
|
+
stale_days?: number | undefined;
|
|
237
|
+
stuck_days?: number | undefined;
|
|
238
|
+
large_pr_lines?: number | undefined;
|
|
239
|
+
} | undefined;
|
|
240
|
+
timezone?: string | undefined;
|
|
241
|
+
cache?: {
|
|
242
|
+
path?: string | undefined;
|
|
243
|
+
ttl_hours?: number | undefined;
|
|
244
|
+
sync_ttl_hours?: number | undefined;
|
|
245
|
+
concurrency?: number | undefined;
|
|
246
|
+
} | undefined;
|
|
247
|
+
}>;
|
|
248
|
+
export {};
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
2
|
+
import { execSync } from 'node:child_process';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import YAML from 'yaml';
|
|
7
|
+
const TeamStrategySchema = z.enum(['org_members', 'config_list', 'repo_contributors']);
|
|
8
|
+
const ExcludeSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
bots: z.boolean().default(true),
|
|
11
|
+
forks: z.boolean().default(true),
|
|
12
|
+
archived: z.boolean().default(true),
|
|
13
|
+
authors: z.array(z.string().min(1)).default([]),
|
|
14
|
+
})
|
|
15
|
+
.default({
|
|
16
|
+
bots: true,
|
|
17
|
+
forks: true,
|
|
18
|
+
archived: true,
|
|
19
|
+
authors: [],
|
|
20
|
+
});
|
|
21
|
+
const ThresholdsSchema = z
|
|
22
|
+
.object({
|
|
23
|
+
stale_days: z.number().int().positive().default(2),
|
|
24
|
+
stuck_days: z.number().int().positive().default(4),
|
|
25
|
+
large_pr_lines: z.number().int().positive().default(500),
|
|
26
|
+
})
|
|
27
|
+
.default({
|
|
28
|
+
stale_days: 2,
|
|
29
|
+
stuck_days: 4,
|
|
30
|
+
large_pr_lines: 500,
|
|
31
|
+
});
|
|
32
|
+
const CacheSchema = z
|
|
33
|
+
.object({
|
|
34
|
+
path: z.string().default(''),
|
|
35
|
+
ttl_hours: z.number().int().positive().default(1),
|
|
36
|
+
sync_ttl_hours: z.number().int().nonnegative().default(24),
|
|
37
|
+
concurrency: z.number().int().positive().default(5),
|
|
38
|
+
})
|
|
39
|
+
.default({
|
|
40
|
+
path: '',
|
|
41
|
+
ttl_hours: 1,
|
|
42
|
+
sync_ttl_hours: 24,
|
|
43
|
+
concurrency: 5,
|
|
44
|
+
});
|
|
45
|
+
const TeamSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
strategy: TeamStrategySchema.default('org_members'),
|
|
48
|
+
members: z.array(z.string().min(1)).default([]),
|
|
49
|
+
})
|
|
50
|
+
.default({
|
|
51
|
+
strategy: 'org_members',
|
|
52
|
+
members: [],
|
|
53
|
+
});
|
|
54
|
+
const ConfigSchema = z.object({
|
|
55
|
+
github_token: z.string().optional(),
|
|
56
|
+
linear_api_key: z.string().min(1).optional(),
|
|
57
|
+
orgs: z.array(z.string().min(1)).default([]),
|
|
58
|
+
repos: z.array(z.string().min(1)).default([]),
|
|
59
|
+
team: TeamSchema,
|
|
60
|
+
exclude: ExcludeSchema,
|
|
61
|
+
thresholds: ThresholdsSchema,
|
|
62
|
+
timezone: z.string().default(''),
|
|
63
|
+
cache: CacheSchema,
|
|
64
|
+
});
|
|
65
|
+
// Internal schema with required token (after resolution)
|
|
66
|
+
const ResolvedConfigSchema = ConfigSchema.extend({
|
|
67
|
+
github_token: z.string().min(1),
|
|
68
|
+
});
|
|
69
|
+
export const DEFAULT_CONFIG_ENV = 'GH_PULSE_CONFIG';
|
|
70
|
+
/**
|
|
71
|
+
* Try to get GitHub token from `gh` CLI.
|
|
72
|
+
* Returns undefined if gh is not available or not authenticated.
|
|
73
|
+
*/
|
|
74
|
+
export function getGhCliToken() {
|
|
75
|
+
try {
|
|
76
|
+
const token = execSync('gh auth token', {
|
|
77
|
+
encoding: 'utf8',
|
|
78
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
79
|
+
timeout: 5000,
|
|
80
|
+
}).trim();
|
|
81
|
+
return token.length > 0 ? token : undefined;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function resolveConfigPath(providedPath, env = process.env) {
|
|
88
|
+
if (providedPath) {
|
|
89
|
+
return expandHome(providedPath);
|
|
90
|
+
}
|
|
91
|
+
const envPath = env[DEFAULT_CONFIG_ENV];
|
|
92
|
+
if (envPath && envPath.trim().length > 0) {
|
|
93
|
+
return expandHome(envPath.trim());
|
|
94
|
+
}
|
|
95
|
+
const xdgConfigHome = env.XDG_CONFIG_HOME;
|
|
96
|
+
const base = xdgConfigHome && xdgConfigHome.trim().length > 0
|
|
97
|
+
? xdgConfigHome.trim()
|
|
98
|
+
: path.join(os.homedir(), '.config');
|
|
99
|
+
return path.join(base, 'gh-pulse', 'config.yaml');
|
|
100
|
+
}
|
|
101
|
+
export function resolveCachePath(configuredPath, env = process.env) {
|
|
102
|
+
if (configuredPath && configuredPath.trim().length > 0) {
|
|
103
|
+
return expandHome(configuredPath.trim());
|
|
104
|
+
}
|
|
105
|
+
const xdgCacheHome = env.XDG_CACHE_HOME;
|
|
106
|
+
const base = xdgCacheHome && xdgCacheHome.trim().length > 0
|
|
107
|
+
? xdgCacheHome.trim()
|
|
108
|
+
: path.join(os.homedir(), '.cache');
|
|
109
|
+
return path.join(base, 'gh-pulse', 'cache.db');
|
|
110
|
+
}
|
|
111
|
+
export async function loadConfig(options = {}) {
|
|
112
|
+
const env = options.env ?? process.env;
|
|
113
|
+
const configPath = resolveConfigPath(options.path, env);
|
|
114
|
+
const rawText = await fs.readFile(configPath, 'utf8');
|
|
115
|
+
const parsed = YAML.parse(rawText) ?? {};
|
|
116
|
+
// Resolve env placeholders, allowing GITHUB_TOKEN to be missing
|
|
117
|
+
const resolved = resolveEnvPlaceholders(parsed, env, ['GITHUB_TOKEN']);
|
|
118
|
+
const parsedConfig = ConfigSchema.parse(resolved);
|
|
119
|
+
// Resolve GitHub token: config > env > gh CLI
|
|
120
|
+
let githubToken = parsedConfig.github_token;
|
|
121
|
+
if (!githubToken || githubToken.trim().length === 0) {
|
|
122
|
+
// Try gh CLI as fallback
|
|
123
|
+
githubToken = getGhCliToken();
|
|
124
|
+
}
|
|
125
|
+
if (!githubToken || githubToken.trim().length === 0) {
|
|
126
|
+
throw new Error('GitHub token not found. Provide github_token in config, set GITHUB_TOKEN env var, or authenticate with `gh auth login`');
|
|
127
|
+
}
|
|
128
|
+
const timezone = parsedConfig.timezone.trim().length > 0
|
|
129
|
+
? parsedConfig.timezone
|
|
130
|
+
: Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC';
|
|
131
|
+
return ResolvedConfigSchema.parse({
|
|
132
|
+
...parsedConfig,
|
|
133
|
+
github_token: githubToken,
|
|
134
|
+
timezone,
|
|
135
|
+
cache: {
|
|
136
|
+
...parsedConfig.cache,
|
|
137
|
+
path: resolveCachePath(parsedConfig.cache.path, env),
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function resolveEnvPlaceholders(value, env, allowMissing = []) {
|
|
142
|
+
if (Array.isArray(value)) {
|
|
143
|
+
return value.map((item) => resolveEnvPlaceholders(item, env, allowMissing));
|
|
144
|
+
}
|
|
145
|
+
if (value && typeof value === 'object') {
|
|
146
|
+
const entries = Object.entries(value);
|
|
147
|
+
return Object.fromEntries(entries.map(([key, val]) => [key, resolveEnvPlaceholders(val, env, allowMissing)]));
|
|
148
|
+
}
|
|
149
|
+
if (typeof value === 'string') {
|
|
150
|
+
return substituteEnv(value, env, allowMissing);
|
|
151
|
+
}
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
function substituteEnv(value, env, allowMissing = []) {
|
|
155
|
+
return value.replace(/\$\{([A-Z0-9_]+)\}/gi, (_, name) => {
|
|
156
|
+
const replacement = env[name];
|
|
157
|
+
if (!replacement || replacement.trim().length === 0) {
|
|
158
|
+
if (allowMissing.includes(name)) {
|
|
159
|
+
return ''; // Return empty string, will be handled by fallback logic
|
|
160
|
+
}
|
|
161
|
+
throw new Error(`Missing environment variable for ${name}`);
|
|
162
|
+
}
|
|
163
|
+
return replacement;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function expandHome(value) {
|
|
167
|
+
if (!value.startsWith('~')) {
|
|
168
|
+
return value;
|
|
169
|
+
}
|
|
170
|
+
return path.join(os.homedir(), value.slice(1));
|
|
171
|
+
}
|
|
172
|
+
export const CONFIG_SCHEMA = ConfigSchema;
|
package/dist/filters.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isBotUsername = isBotUsername;
|
|
4
|
+
exports.isExcludedAuthor = isExcludedAuthor;
|
|
5
|
+
function isBotUsername(username) {
|
|
6
|
+
return /\[bot\]$/i.test(username);
|
|
7
|
+
}
|
|
8
|
+
function isExcludedAuthor(username, exclude, excludeBots) {
|
|
9
|
+
if (exclude.has(username)) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
if (excludeBots && isBotUsername(username)) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|