@theholocron/holocron-plugin-github 5.0.0-alpha.517 → 5.0.0-alpha.519
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/index.d.mts +23 -2
- package/dist/index.mjs +88 -35
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* receives plugin-level options from `holocron.config.json` and
|
|
8
8
|
* returns the bound implementation.
|
|
9
9
|
*/
|
|
10
|
-
import { AddedItem, Auth, AuthError, BoardItem, BoardItemInput, BoardState, BoardSummary, BoardTemplate, Ci, CiRun, CiRunFilter, EnsureRelaySourceInput, EnsureRelaySourceResult, EnsureReport, Environment, Environments, ExportInfo, ImportOptions, ImportResult, InspectRelaySourceInput, Issue, IssueCreateInput, IssuePatch, IssueRecord, IssueSearchFilter, IssueSelector, IssueUpdateResult, Issues, LabelDef, LifecycleResult, LifecycleSlot, MoveReport, PagesConfig, PluginToken, Projects, PullRequest, PullRequestChecks, PullRequestInput, PullRequestPatch, PullRequestResult, RelaySourceState, RepoRef, RepoSettings, ResolveTokenInput, Ruleset, SecretAccess, SecretScope, Secrets, Source, SourceBranch, SourceFile, SourceRepoInfo, SourceRulesetDetail, SourceSecurity, SourceTeamMember, SyncResult, TeamEntry, TeamEntry as TeamEntry$1, TeamPermission, TeamPermission as TeamPermission$1, TrackerDoctorReport, TrackerUser, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess, createFeatureResolver } from "@theholocron/cli";
|
|
10
|
+
import { AddedItem, Auth, AuthError, BoardItem, BoardItemInput, BoardState, BoardSummary, BoardTemplate, Ci, CiRun, CiRunFilter, EnsureRelaySourceInput, EnsureRelaySourceResult, EnsureReport, Environment, Environments, ExportInfo, ImportOptions, ImportResult, InspectRelaySourceInput, Issue, IssueCreateInput, IssuePatch, IssueRecord, IssueSearchFilter, IssueSelector, IssueTypeDeclaration, IssueTypeInfo, IssueUpdateResult, Issues, LabelDef, LifecycleResult, LifecycleSlot, MoveReport, PagesConfig, PluginToken, Projects, PullRequest, PullRequestChecks, PullRequestInput, PullRequestPatch, PullRequestResult, RelaySourceState, RepoRef, RepoSettings, ResolveTokenInput, Ruleset, SecretAccess, SecretScope, Secrets, Source, SourceBranch, SourceFile, SourceRepoInfo, SourceRulesetDetail, SourceSecurity, SourceTeamMember, SyncResult, TeamEntry, TeamEntry as TeamEntry$1, TeamPermission, TeamPermission as TeamPermission$1, TrackerDoctorReport, TrackerUser, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess, createFeatureResolver } from "@theholocron/cli";
|
|
11
11
|
import { GitHubClient, GitHubClientOptions, GraphQLClient, createGitHubClient } from "@theholocron/github-client";
|
|
12
12
|
/** Resolves the token for read-only GitHub access (`HOLOCRON_READ_TOKEN`, keyring key `github.read`). */
|
|
13
13
|
export declare const resolveReadToken: import("@theholocron/cli").FeatureResolver;
|
|
@@ -92,6 +92,15 @@ interface IssuesOptions {
|
|
|
92
92
|
inProgress: string;
|
|
93
93
|
inReview: string;
|
|
94
94
|
};
|
|
95
|
+
/** The organization's issue Types (`issueTypes`), which `--type` and a record's kind are written as. */
|
|
96
|
+
issueTypes?: ReadonlyArray<{
|
|
97
|
+
name: string;
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* A client with the organization token (`HOLOCRON_ORG_TOKEN`, Issue types read and write), for the Type methods
|
|
101
|
+
* only; `undefined` when none is configured. The shared issues token never writes the organization's vocabulary.
|
|
102
|
+
*/
|
|
103
|
+
orgClient?: () => GitHubClient | undefined;
|
|
95
104
|
}
|
|
96
105
|
/** The GitHub implementation of the `issues` capability, backed by GitHub Issues and status labels. */
|
|
97
106
|
export declare class GitHubIssues implements Issues {
|
|
@@ -104,6 +113,8 @@ export declare class GitHubIssues implements Issues {
|
|
|
104
113
|
private readonly repoName;
|
|
105
114
|
private readonly repo;
|
|
106
115
|
private readonly labels;
|
|
116
|
+
private readonly kinds;
|
|
117
|
+
private readonly orgClient;
|
|
107
118
|
constructor(client: GitHubClient, opts: IssuesOptions);
|
|
108
119
|
getMyself(): Promise<TrackerUser>;
|
|
109
120
|
/**
|
|
@@ -142,6 +153,12 @@ export declare class GitHubIssues implements Issues {
|
|
|
142
153
|
import(records: IssueRecord[], options?: ImportOptions): Promise<ImportResult[]>;
|
|
143
154
|
/** Like `import`, and it also updates what an earlier import or sync made, for `holocron sync issues`. */
|
|
144
155
|
sync(records: IssueRecord[], options?: ImportOptions): Promise<SyncResult[]>;
|
|
156
|
+
listTypes(): Promise<IssueTypeInfo[] | undefined>;
|
|
157
|
+
createType(type: IssueTypeDeclaration): Promise<IssueTypeInfo>;
|
|
158
|
+
updateType(id: IssueTypeInfo["id"], patch: {
|
|
159
|
+
description?: string;
|
|
160
|
+
color?: string;
|
|
161
|
+
}): Promise<void>;
|
|
145
162
|
private fieldSetter;
|
|
146
163
|
/** What the field writers need; the setter is shared so the organization's field list is read once. */
|
|
147
164
|
private fieldContext;
|
|
@@ -453,6 +470,10 @@ export interface GitHubPluginOptions extends ResolveTokenInput {
|
|
|
453
470
|
};
|
|
454
471
|
/** `repo.labels` (the area map), handed in by the loader for the `issue-types` probe. */
|
|
455
472
|
areaLabels?: LabelsConfig;
|
|
473
|
+
/** The organization's issue Types (`issueTypes`, #2512), handed in by the loader: the names a kind is written as. */
|
|
474
|
+
issueTypes?: ReadonlyArray<{
|
|
475
|
+
name: string;
|
|
476
|
+
}>;
|
|
456
477
|
/** Override base URL for tests. Defaults to https://api.github.com. */
|
|
457
478
|
baseUrl?: string;
|
|
458
479
|
/** Override `fetch` for tests. Defaults to global `fetch`. */
|
|
@@ -478,7 +499,7 @@ export declare function environments(ctx: PluginContext): Environments;
|
|
|
478
499
|
/** Builds the `ci` capability. */
|
|
479
500
|
export declare function ci(ctx: PluginContext): Ci;
|
|
480
501
|
/** Builds the `issues` capability, passing the lifecycle labels when configured. */
|
|
481
|
-
export declare function issues(ctx: PluginContext): Issues;
|
|
502
|
+
export declare function issues(ctx: PluginContext, orgClient?: () => GitHubClient | undefined): Issues;
|
|
482
503
|
/** Builds the `projects` capability: GitHub Projects v2 over GraphQL, with items keyed relative to the configured repo. */
|
|
483
504
|
export declare function projects(ctx: PluginContext): Projects;
|
|
484
505
|
/** Creates the plugin, resolving a token per capability when it is first used. */
|
package/dist/index.mjs
CHANGED
|
@@ -263,8 +263,8 @@ function createFieldSetter(client, repo) {
|
|
|
263
263
|
};
|
|
264
264
|
}
|
|
265
265
|
// src/capabilities/issue-kind.ts
|
|
266
|
-
/** The Type name of each kind. */
|
|
267
|
-
const
|
|
266
|
+
/** The Type name of each core kind; always known, whatever is declared. */
|
|
267
|
+
const CORE_TYPE_NAMES = {
|
|
268
268
|
bug: "Bug",
|
|
269
269
|
feature: "Feature",
|
|
270
270
|
task: "Task"
|
|
@@ -275,21 +275,34 @@ const LABEL_KINDS = {
|
|
|
275
275
|
enhancement: "feature",
|
|
276
276
|
chore: "task"
|
|
277
277
|
};
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const
|
|
278
|
+
/** The core three Types plus the declared ones (in the declaration's spelling); a core name wins over a declared one. */
|
|
279
|
+
function kindNames(declared) {
|
|
280
|
+
const names = new Map(Object.entries(CORE_TYPE_NAMES));
|
|
281
|
+
for (const { name } of declared ?? []) if (!names.has(name.toLowerCase())) names.set(name.toLowerCase(), name);
|
|
282
|
+
return {
|
|
283
|
+
nameOf: (kind) => names.get(kind) ?? kind.charAt(0).toUpperCase() + kind.slice(1),
|
|
284
|
+
kindOf: (typeName) => typeName ? typeName.toLowerCase() : void 0
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/** The names with nothing declared. */
|
|
288
|
+
const CORE_KIND_NAMES = kindNames(void 0);
|
|
289
|
+
/**
|
|
290
|
+
* The kind of an issue: its Type (a Type outside the core three is its lower-case name, so a migration does not lose an
|
|
291
|
+
* Epic), else the one kind its labels name (two different ones name none).
|
|
292
|
+
*/
|
|
293
|
+
function kindOfIssue(issue, names = CORE_KIND_NAMES) {
|
|
294
|
+
const typed = names.kindOf(issue.type?.name);
|
|
282
295
|
if (typed) return typed;
|
|
283
296
|
const named = new Set(issue.labels.flatMap((l) => LABEL_KINDS[l.name.toLowerCase()] ?? []));
|
|
284
297
|
return named.size === 1 ? [...named][0] : void 0;
|
|
285
298
|
}
|
|
286
299
|
/** Whether the issue's Type is already the kind's. */
|
|
287
|
-
function hasKindType(issue, kind) {
|
|
288
|
-
return issue.type?.name?.toLowerCase() ===
|
|
300
|
+
function hasKindType(issue, kind, names = CORE_KIND_NAMES) {
|
|
301
|
+
return issue.type?.name?.toLowerCase() === names.nameOf(kind).toLowerCase();
|
|
289
302
|
}
|
|
290
303
|
/** Sets the Type of issue `number`; a refusal is returned as a `dropped` line, anything else (a rate limit) is thrown. */
|
|
291
|
-
async function writeKind(client, repo, number, kind) {
|
|
292
|
-
const name =
|
|
304
|
+
async function writeKind(client, repo, number, kind, names = CORE_KIND_NAMES) {
|
|
305
|
+
const name = names.nameOf(kind);
|
|
293
306
|
try {
|
|
294
307
|
await client.issues.updateIssue(repo, number, { type: name });
|
|
295
308
|
return;
|
|
@@ -383,12 +396,12 @@ function explainSecondaryLimit(err) {
|
|
|
383
396
|
* fetched a few at a time until enough are kept; a listing already carries `created_at`, so it is cut before the
|
|
384
397
|
* per-issue comment and link requests. `info.matched` receives how many the selection matched before the cut.
|
|
385
398
|
*/
|
|
386
|
-
async function exportIssues(client, repo, selector, info = {}) {
|
|
387
|
-
return readIssues(client, repo, selector, info).catch((err) => {
|
|
399
|
+
async function exportIssues(client, repo, selector, info = {}, kinds = CORE_KIND_NAMES) {
|
|
400
|
+
return readIssues(client, repo, selector, info, kinds).catch((err) => {
|
|
388
401
|
throw explainSecondaryLimit(err);
|
|
389
402
|
});
|
|
390
403
|
}
|
|
391
|
-
async function readIssues(client, repo, selector, info) {
|
|
404
|
+
async function readIssues(client, repo, selector, info, kinds) {
|
|
392
405
|
const [owner = "", name = ""] = repo.split("/", 2);
|
|
393
406
|
const since = selector.since ? Date.parse(selector.since) : void 0;
|
|
394
407
|
const survives = (i) => !i.pull_request && !(selector.openOnly && i.state === "closed") && (since === void 0 || Date.parse(i.updated_at) >= since);
|
|
@@ -429,7 +442,7 @@ async function readIssues(client, repo, selector, info) {
|
|
|
429
442
|
const { labels, priority } = splitLabels(issue.labels.map((l) => l.name));
|
|
430
443
|
const body = issue.body?.replace(MARKER, "").trimEnd();
|
|
431
444
|
const migratedFrom = issue.body ? MARKER.exec(issue.body)?.[1] : void 0;
|
|
432
|
-
const kind = kindOfIssue(issue);
|
|
445
|
+
const kind = kindOfIssue(issue, kinds);
|
|
433
446
|
records.push({
|
|
434
447
|
key: `#${issue.number}`,
|
|
435
448
|
url: issue.html_url,
|
|
@@ -462,7 +475,7 @@ async function readIssues(client, repo, selector, info) {
|
|
|
462
475
|
return records;
|
|
463
476
|
}
|
|
464
477
|
/** Makes the records as issues, skipping any whose source address an earlier run already recorded. */
|
|
465
|
-
async function importIssues(client, repo, records, options = {}) {
|
|
478
|
+
async function importIssues(client, repo, records, options = {}, kinds = CORE_KIND_NAMES) {
|
|
466
479
|
const existing = /* @__PURE__ */ new Map();
|
|
467
480
|
for (const issue of await listAll(client, repo, {})) {
|
|
468
481
|
const url = issue.body ? MARKER.exec(issue.body)?.[1] : void 0;
|
|
@@ -496,7 +509,7 @@ async function importIssues(client, repo, records, options = {}) {
|
|
|
496
509
|
const number = await createFromRecord(client, repo, record, options);
|
|
497
510
|
const field = await priority.set(number, record.priority, { isNew: true });
|
|
498
511
|
if (field.note) dropped.push(field.note);
|
|
499
|
-
const kindNote = record.kind ? await writeKind(client, repo, number, record.kind) : void 0;
|
|
512
|
+
const kindNote = record.kind ? await writeKind(client, repo, number, record.kind, kinds) : void 0;
|
|
500
513
|
if (kindNote) dropped.push(kindNote);
|
|
501
514
|
results.push({
|
|
502
515
|
source: record.key,
|
|
@@ -580,7 +593,7 @@ function isRateLimited(err) {
|
|
|
580
593
|
const normalize = (text) => text.replace(/\r\n/g, "\n").trim();
|
|
581
594
|
const sorted = (names) => names.map((n) => n.toLowerCase()).sort().join("\n");
|
|
582
595
|
/** Makes the records missing from the repo and updates the ones an earlier run made. See the file comment. */
|
|
583
|
-
async function syncIssues(client, repo, records, options = {}) {
|
|
596
|
+
async function syncIssues(client, repo, records, options = {}, kinds = CORE_KIND_NAMES) {
|
|
584
597
|
const existing = /* @__PURE__ */ new Map();
|
|
585
598
|
for (const issue of await listAll(client, repo, {})) {
|
|
586
599
|
const url = issue.body ? MARKER.exec(issue.body)?.[1] : void 0;
|
|
@@ -590,7 +603,7 @@ async function syncIssues(client, repo, records, options = {}) {
|
|
|
590
603
|
const results = [];
|
|
591
604
|
for (const record of records) try {
|
|
592
605
|
const found = existing.get(record.url);
|
|
593
|
-
results.push(found ? await update(client, repo, found, record, options, priority) : await create(client, repo, record, options, priority));
|
|
606
|
+
results.push(found ? await update(client, repo, found, record, options, priority, kinds) : await create(client, repo, record, options, priority, kinds));
|
|
594
607
|
reportProgress(options.onProgress, results.length, records.length);
|
|
595
608
|
} catch (err) {
|
|
596
609
|
if (isRateLimited(err)) return results;
|
|
@@ -598,7 +611,7 @@ async function syncIssues(client, repo, records, options = {}) {
|
|
|
598
611
|
}
|
|
599
612
|
return results;
|
|
600
613
|
}
|
|
601
|
-
async function create(client, repo, record, options, priority) {
|
|
614
|
+
async function create(client, repo, record, options, priority, kinds) {
|
|
602
615
|
const dropped = droppedFor(record);
|
|
603
616
|
if (options.dryRun) return {
|
|
604
617
|
source: record.key,
|
|
@@ -610,7 +623,7 @@ async function create(client, repo, record, options, priority) {
|
|
|
610
623
|
const number = await createFromRecord(client, repo, record, options);
|
|
611
624
|
const field = await priority.set(number, record.priority, { isNew: true });
|
|
612
625
|
if (field.note) dropped.push(field.note);
|
|
613
|
-
const kindNote = record.kind ? await writeKind(client, repo, number, record.kind) : void 0;
|
|
626
|
+
const kindNote = record.kind ? await writeKind(client, repo, number, record.kind, kinds) : void 0;
|
|
614
627
|
if (kindNote) dropped.push(kindNote);
|
|
615
628
|
return {
|
|
616
629
|
source: record.key,
|
|
@@ -621,7 +634,7 @@ async function create(client, repo, record, options, priority) {
|
|
|
621
634
|
dropped
|
|
622
635
|
};
|
|
623
636
|
}
|
|
624
|
-
async function update(client, repo, issue, record, options, priority) {
|
|
637
|
+
async function update(client, repo, issue, record, options, priority, kinds) {
|
|
625
638
|
const patch = {};
|
|
626
639
|
const changes = [];
|
|
627
640
|
if (issue.title !== record.title) {
|
|
@@ -651,9 +664,9 @@ async function update(client, repo, issue, record, options, priority) {
|
|
|
651
664
|
}
|
|
652
665
|
const field = await priority.set(issue.number, record.priority, { dryRun: options.dryRun });
|
|
653
666
|
if (field.changed) changes.push("priority field");
|
|
654
|
-
const kindWrong = record.kind !== void 0 && !hasKindType(issue, record.kind);
|
|
667
|
+
const kindWrong = record.kind !== void 0 && !hasKindType(issue, record.kind, kinds);
|
|
655
668
|
if (kindWrong) changes.push("kind");
|
|
656
|
-
const kindNote = kindWrong && !options.dryRun ? await writeKind(client, repo, issue.number, record.kind) : void 0;
|
|
669
|
+
const kindNote = kindWrong && !options.dryRun ? await writeKind(client, repo, issue.number, record.kind, kinds) : void 0;
|
|
657
670
|
const comments = await client.issues.listComments(repo, issue.number);
|
|
658
671
|
const seen = new Set(comments.map((c) => COMMENT_HEADER.exec(c.body)?.[1]));
|
|
659
672
|
const missing = record.comments.filter((c) => !seen.has(c.createdAt));
|
|
@@ -676,11 +689,6 @@ async function update(client, repo, issue, record, options, priority) {
|
|
|
676
689
|
};
|
|
677
690
|
}
|
|
678
691
|
// src/capabilities/issues-update.ts
|
|
679
|
-
const KIND_NAMES = {
|
|
680
|
-
bug: "Bug",
|
|
681
|
-
feature: "Feature",
|
|
682
|
-
task: "Task"
|
|
683
|
-
};
|
|
684
692
|
const EFFORT_NAMES = {
|
|
685
693
|
high: "High",
|
|
686
694
|
medium: "Medium",
|
|
@@ -729,7 +737,7 @@ async function applyIssueFields(ctx, issue, input, isNew) {
|
|
|
729
737
|
const flags = { isNew };
|
|
730
738
|
const clear = new Set(input.clear ?? []);
|
|
731
739
|
if (input.kind) {
|
|
732
|
-
const name =
|
|
740
|
+
const name = ctx.kinds.nameOf(input.kind);
|
|
733
741
|
if (issue.type?.name?.toLowerCase() !== name.toLowerCase()) await guarded(`kind ${name}`, out, async () => {
|
|
734
742
|
await client.issues.updateIssue(repo, issue.number, { type: name });
|
|
735
743
|
out.changed.push(`kind: ${name}`);
|
|
@@ -889,6 +897,16 @@ async function updateGitHubIssue(ctx, key, patch) {
|
|
|
889
897
|
const TEXT_PAGE_SIZE = 100;
|
|
890
898
|
/** Pages `search` reads for a `text` before it stops (the 2000 most recently updated issues). */
|
|
891
899
|
const TEXT_MAX_PAGES = 20;
|
|
900
|
+
/** A Type as the capability reports it: GitHub's `null`s are left out. */
|
|
901
|
+
function toTypeInfo(t) {
|
|
902
|
+
return {
|
|
903
|
+
id: t.id,
|
|
904
|
+
name: t.name,
|
|
905
|
+
...t.description ? { description: t.description } : {},
|
|
906
|
+
...t.color ? { color: t.color } : {},
|
|
907
|
+
enabled: t.is_enabled
|
|
908
|
+
};
|
|
909
|
+
}
|
|
892
910
|
/** The GitHub implementation of the `issues` capability, backed by GitHub Issues and status labels. */
|
|
893
911
|
var GitHubIssues = class {
|
|
894
912
|
client;
|
|
@@ -900,6 +918,8 @@ var GitHubIssues = class {
|
|
|
900
918
|
repoName;
|
|
901
919
|
repo;
|
|
902
920
|
labels;
|
|
921
|
+
kinds;
|
|
922
|
+
orgClient;
|
|
903
923
|
constructor(client, opts) {
|
|
904
924
|
this.client = client;
|
|
905
925
|
const [owner = "", repoName = ""] = opts.repo.split("/", 2);
|
|
@@ -907,6 +927,8 @@ var GitHubIssues = class {
|
|
|
907
927
|
this.repoName = repoName;
|
|
908
928
|
this.repo = opts.repo;
|
|
909
929
|
this.labels = opts.labels;
|
|
930
|
+
this.kinds = kindNames(opts.issueTypes);
|
|
931
|
+
this.orgClient = opts.orgClient;
|
|
910
932
|
}
|
|
911
933
|
async getMyself() {
|
|
912
934
|
const raw = await this.client.user.getCurrentUser();
|
|
@@ -1128,15 +1150,43 @@ var GitHubIssues = class {
|
|
|
1128
1150
|
}
|
|
1129
1151
|
/** Reads issues with their comments, priority label, parent and blockers, for `holocron migrate`. */
|
|
1130
1152
|
export(selector, info) {
|
|
1131
|
-
return exportIssues(this.client, this.repo, selector, info);
|
|
1153
|
+
return exportIssues(this.client, this.repo, selector, info, this.kinds);
|
|
1132
1154
|
}
|
|
1133
1155
|
/** Makes the records as issues; one already made by an earlier run is skipped. */
|
|
1134
1156
|
import(records, options) {
|
|
1135
|
-
return importIssues(this.client, this.repo, records, options);
|
|
1157
|
+
return importIssues(this.client, this.repo, records, options, this.kinds);
|
|
1136
1158
|
}
|
|
1137
1159
|
/** Like `import`, and it also updates what an earlier import or sync made, for `holocron sync issues`. */
|
|
1138
1160
|
sync(records, options) {
|
|
1139
|
-
return syncIssues(this.client, this.repo, records, options);
|
|
1161
|
+
return syncIssues(this.client, this.repo, records, options, this.kinds);
|
|
1162
|
+
}
|
|
1163
|
+
async listTypes() {
|
|
1164
|
+
const client = this.orgClient?.();
|
|
1165
|
+
return client ? (await client.issueTypes.list(this.owner)).map(toTypeInfo) : void 0;
|
|
1166
|
+
}
|
|
1167
|
+
async createType(type) {
|
|
1168
|
+
const client = this.orgClient?.();
|
|
1169
|
+
if (!client) throw new Error("no organization token (HOLOCRON_ORG_TOKEN) to make an issue Type with");
|
|
1170
|
+
return toTypeInfo(await client.issueTypes.create(this.owner, {
|
|
1171
|
+
name: type.name,
|
|
1172
|
+
is_enabled: type.enabled ?? true,
|
|
1173
|
+
...type.description !== void 0 ? { description: type.description } : {},
|
|
1174
|
+
...type.color !== void 0 ? { color: type.color } : {}
|
|
1175
|
+
}));
|
|
1176
|
+
}
|
|
1177
|
+
async updateType(id, patch) {
|
|
1178
|
+
const client = this.orgClient?.();
|
|
1179
|
+
if (!client) throw new Error("no organization token (HOLOCRON_ORG_TOKEN) to change an issue Type with");
|
|
1180
|
+
const current = (await client.issueTypes.list(this.owner)).find((t) => String(t.id) === String(id));
|
|
1181
|
+
if (!current) throw new Error(`the organization has no issue Type with id ${id}`);
|
|
1182
|
+
const description = patch.description ?? current.description;
|
|
1183
|
+
const color = patch.color ?? current.color;
|
|
1184
|
+
await client.issueTypes.update(this.owner, current.id, {
|
|
1185
|
+
name: current.name,
|
|
1186
|
+
is_enabled: current.is_enabled,
|
|
1187
|
+
...description != null ? { description } : {},
|
|
1188
|
+
...color != null ? { color } : {}
|
|
1189
|
+
});
|
|
1140
1190
|
}
|
|
1141
1191
|
fieldSetter;
|
|
1142
1192
|
/** What the field writers need; the setter is shared so the organization's field list is read once. */
|
|
@@ -1146,7 +1196,8 @@ var GitHubIssues = class {
|
|
|
1146
1196
|
client: this.client,
|
|
1147
1197
|
repo: this.repo,
|
|
1148
1198
|
parseKey: (k) => parseIssueNumber(k, this.owner, this.repoName),
|
|
1149
|
-
fields: this.fieldSetter
|
|
1199
|
+
fields: this.fieldSetter,
|
|
1200
|
+
kinds: this.kinds
|
|
1150
1201
|
};
|
|
1151
1202
|
}
|
|
1152
1203
|
async resolveMilestone(ref) {
|
|
@@ -4206,9 +4257,11 @@ function ci(ctx) {
|
|
|
4206
4257
|
return new GitHubCi(ctx.client, { repo: ctx.repo });
|
|
4207
4258
|
}
|
|
4208
4259
|
/** Builds the `issues` capability, passing the lifecycle labels when configured. */
|
|
4209
|
-
function issues(ctx) {
|
|
4260
|
+
function issues(ctx, orgClient) {
|
|
4210
4261
|
const opts = { repo: ctx.repo };
|
|
4211
4262
|
if (ctx.options.labels !== void 0) opts.labels = ctx.options.labels;
|
|
4263
|
+
if (ctx.options.issueTypes !== void 0) opts.issueTypes = ctx.options.issueTypes;
|
|
4264
|
+
if (orgClient) opts.orgClient = orgClient;
|
|
4212
4265
|
return new GitHubIssues(ctx.client, opts);
|
|
4213
4266
|
}
|
|
4214
4267
|
/** Builds the `projects` capability: GitHub Projects v2 over GraphQL, with items keyed relative to the configured repo. */
|
|
@@ -4316,7 +4369,7 @@ function createPlugin(options) {
|
|
|
4316
4369
|
ci: () => ci(makeCtx(resolveReadToken)),
|
|
4317
4370
|
secrets: () => makeSecrets(),
|
|
4318
4371
|
environments: () => environments(makeCtx(resolveAdminToken)),
|
|
4319
|
-
issues: () => issues(makeCtx(resolveIssuesToken)),
|
|
4372
|
+
issues: () => issues(makeCtx(resolveIssuesToken), makeOrgClient),
|
|
4320
4373
|
projects: () => projects(makeCtx(resolveOrgToken))
|
|
4321
4374
|
}
|
|
4322
4375
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-github",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.519",
|
|
4
4
|
"description": "Holocron plugin for GitHub. Implements source, ci, secrets, environments, and issues capabilities against the GitHub REST API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ci",
|
|
@@ -44,21 +44,21 @@
|
|
|
44
44
|
"tsx": "4.23.15",
|
|
45
45
|
"typescript": "^6.0.3",
|
|
46
46
|
"vitest": "^5.1.0",
|
|
47
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
47
|
+
"@theholocron/cli": "5.0.0-alpha.519",
|
|
48
48
|
"@theholocron/eslint-config": "^8.9.0-alpha.22",
|
|
49
|
+
"@theholocron/github-client": "^1.58.0-alpha.52",
|
|
50
|
+
"@theholocron/misc-utils": "^1.17.0-alpha.5",
|
|
49
51
|
"@theholocron/fs-utils": "^1.17.0-alpha.5",
|
|
50
|
-
"@theholocron/
|
|
51
|
-
"@theholocron/http-client": "^1.58.0-alpha.51",
|
|
52
|
-
"@theholocron/tsconfig": "^8.9.0-alpha.22",
|
|
52
|
+
"@theholocron/http-client": "^1.58.0-alpha.52",
|
|
53
53
|
"@theholocron/tsdown-config": "^8.9.0-alpha.22",
|
|
54
54
|
"@theholocron/vitest-config": "^8.9.0-alpha.22",
|
|
55
|
-
"@theholocron/
|
|
55
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.22"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@theholocron/fs-utils": "^1.16.0",
|
|
59
59
|
"@theholocron/github-client": "^1.58.0",
|
|
60
60
|
"@theholocron/misc-utils": "^1.16.0",
|
|
61
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
61
|
+
"@theholocron/cli": "5.0.0-alpha.519"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": ">=22"
|