@pecot/workflow-mcp 5.0.0 → 6.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/.claude-plugin/plugin.json +1 -1
- package/README.md +80 -22
- package/cli/dist/cli.js +6 -1
- package/cli/dist/commands/board-add.d.ts +3 -0
- package/cli/dist/commands/board-add.js +59 -0
- package/cli/dist/commands/board-judgment.d.ts +60 -0
- package/cli/dist/commands/board-judgment.js +144 -0
- package/cli/dist/commands/board-move.d.ts +3 -0
- package/cli/dist/commands/board-move.js +57 -0
- package/cli/dist/commands/board-readiness.d.ts +34 -0
- package/cli/dist/commands/board-readiness.js +108 -0
- package/cli/dist/commands/board-show.d.ts +3 -0
- package/cli/dist/commands/board-show.js +72 -0
- package/cli/dist/commands/board-sync.d.ts +3 -0
- package/cli/dist/commands/board-sync.js +111 -0
- package/cli/dist/commands/{project-info.d.ts → board-view.d.ts} +21 -7
- package/cli/dist/commands/{project-info.js → board-view.js} +22 -12
- package/cli/dist/commands/board.d.ts +3 -0
- package/cli/dist/commands/board.js +12 -0
- package/cli/dist/commands/branch.d.ts +3 -0
- package/cli/dist/commands/branch.js +100 -0
- package/cli/dist/commands/command-binding.js +4 -0
- package/cli/dist/commands/command-definition.d.ts +20 -6
- package/cli/dist/commands/command-definition.js +11 -7
- package/cli/dist/commands/command-help.js +2 -2
- package/cli/dist/commands/command-hint.d.ts +5 -0
- package/cli/dist/commands/command-hint.js +13 -0
- package/cli/dist/commands/command-stop.d.ts +5 -3
- package/cli/dist/commands/command-stop.js +7 -6
- package/cli/dist/commands/failure-kind.d.ts +3 -0
- package/cli/dist/commands/failure-kind.js +34 -0
- package/cli/dist/commands/failure.d.ts +6 -0
- package/cli/dist/commands/failure.js +29 -3
- package/cli/dist/commands/github-client.d.ts +6 -2
- package/cli/dist/commands/github-client.js +13 -3
- package/cli/dist/commands/help.js +8 -13
- package/cli/dist/commands/issue-board.d.ts +33 -0
- package/cli/dist/commands/issue-board.js +61 -1
- package/cli/dist/commands/issue-comment.js +47 -28
- package/cli/dist/commands/issue-create.js +548 -91
- package/cli/dist/commands/issue-dependency.d.ts +3 -0
- package/cli/dist/commands/issue-dependency.js +282 -0
- package/cli/dist/commands/issue-readiness.d.ts +94 -0
- package/cli/dist/commands/issue-readiness.js +218 -0
- package/cli/dist/commands/issue-reopen.d.ts +3 -0
- package/cli/dist/commands/issue-reopen.js +115 -0
- package/cli/dist/commands/issue-shared.d.ts +32 -19
- package/cli/dist/commands/issue-shared.js +82 -75
- package/cli/dist/commands/issue-show.d.ts +3 -0
- package/cli/dist/commands/issue-show.js +169 -0
- package/cli/dist/commands/issue.d.ts +0 -1
- package/cli/dist/commands/issue.js +6 -8
- package/cli/dist/commands/names.d.ts +33 -0
- package/cli/dist/commands/names.js +62 -0
- package/cli/dist/commands/output.d.ts +14 -2
- package/cli/dist/commands/output.js +14 -7
- package/cli/dist/commands/pr-waiting.d.ts +20 -0
- package/cli/dist/commands/pr-waiting.js +106 -0
- package/cli/dist/commands/pr.d.ts +19 -0
- package/cli/dist/commands/pr.js +242 -323
- package/cli/dist/commands/project-sync.d.ts +2 -1
- package/cli/dist/commands/project-sync.js +18 -9
- package/cli/dist/commands/project.d.ts +3 -2
- package/cli/dist/commands/project.js +212 -175
- package/cli/dist/commands/registry.js +13 -10
- package/cli/dist/commands/release.d.ts +2 -2
- package/cli/dist/commands/release.js +53 -114
- package/cli/dist/commands/renamed-commands.d.ts +26 -0
- package/cli/dist/commands/renamed-commands.js +53 -0
- package/cli/dist/commands/repository-match.js +3 -2
- package/cli/dist/commands/session-finish.d.ts +3 -0
- package/cli/dist/commands/session-finish.js +267 -0
- package/cli/dist/commands/session-start.d.ts +3 -0
- package/cli/dist/commands/{repository.js → session-start.js} +99 -128
- package/cli/dist/commands/session.d.ts +3 -0
- package/cli/dist/commands/session.js +82 -29
- package/cli/dist/commands/tracker-sync-dependabot.d.ts +7 -0
- package/cli/dist/commands/{dependabot.js → tracker-sync-dependabot.js} +57 -66
- package/cli/dist/commands/tracker-sync-security.d.ts +7 -0
- package/cli/dist/commands/{security.js → tracker-sync-security.js} +50 -61
- package/cli/dist/commands/tracker-sync.d.ts +7 -0
- package/cli/dist/commands/tracker-sync.js +3 -6
- package/cli/dist/commands/tracker.d.ts +3 -0
- package/cli/dist/commands/tracker.js +18 -0
- package/cli/dist/commands/usage-error.d.ts +4 -0
- package/cli/dist/commands/usage-error.js +6 -0
- package/cli/dist/commands/work-target.d.ts +12 -3
- package/cli/dist/commands/work-target.js +46 -5
- package/cli/dist/commands/worktree.js +32 -28
- package/cli/dist/domain/batch-plan.d.ts +73 -0
- package/cli/dist/domain/batch-plan.js +114 -0
- package/cli/dist/domain/blocked-by-change.d.ts +99 -0
- package/cli/dist/domain/blocked-by-change.js +101 -0
- package/cli/dist/domain/board-move.d.ts +90 -0
- package/cli/dist/domain/board-move.js +92 -0
- package/cli/dist/domain/branch-name.js +1 -1
- package/cli/dist/domain/command-hint.d.ts +85 -0
- package/cli/dist/domain/command-hint.js +148 -0
- package/cli/dist/domain/config.d.ts +4 -0
- package/cli/dist/domain/config.js +11 -1
- package/cli/dist/domain/dependabot.js +1 -1
- package/cli/dist/domain/errors.d.ts +5 -0
- package/cli/dist/domain/errors.js +5 -0
- package/cli/dist/domain/format.d.ts +51 -4
- package/cli/dist/domain/format.js +72 -6
- package/cli/dist/domain/frontmatter.d.ts +18 -3
- package/cli/dist/domain/frontmatter.js +38 -12
- package/cli/dist/domain/issue-order.d.ts +55 -0
- package/cli/dist/domain/issue-order.js +65 -0
- package/cli/dist/domain/issue-readout.d.ts +36 -0
- package/cli/dist/domain/pull-request.d.ts +71 -4
- package/cli/dist/domain/pull-request.js +59 -10
- package/cli/dist/domain/readiness.d.ts +27 -0
- package/cli/dist/domain/readiness.js +114 -3
- package/cli/dist/domain/reference-parser.d.ts +3 -1
- package/cli/dist/domain/reference-parser.js +6 -2
- package/cli/dist/domain/release.d.ts +7 -3
- package/cli/dist/domain/release.js +5 -12
- package/cli/dist/domain/repository-policy.d.ts +9 -3
- package/cli/dist/domain/repository-policy.js +8 -7
- package/cli/dist/domain/repository-resolver.js +4 -1
- package/cli/dist/domain/security-alerts.js +1 -1
- package/cli/dist/domain/state.d.ts +30 -0
- package/cli/dist/domain/state.js +39 -0
- package/cli/dist/domain/work-start.d.ts +34 -0
- package/cli/dist/domain/work-start.js +49 -0
- package/cli/dist/infra/authored-notes.d.ts +1 -1
- package/cli/dist/infra/authored-notes.js +10 -4
- package/cli/dist/infra/config-store.d.ts +4 -0
- package/cli/dist/infra/config-store.js +13 -0
- package/cli/dist/infra/git.d.ts +12 -0
- package/cli/dist/infra/git.js +13 -1
- package/cli/dist/infra/github/client.d.ts +5 -0
- package/cli/dist/infra/github/client.js +10 -7
- package/cli/dist/infra/github/errors.d.ts +18 -0
- package/cli/dist/infra/github/errors.js +22 -0
- package/cli/dist/infra/github/issues.d.ts +39 -3
- package/cli/dist/infra/github/issues.js +178 -23
- package/cli/dist/infra/github/projects.d.ts +35 -0
- package/cli/dist/infra/github/projects.js +89 -8
- package/cli/dist/infra/github/pulls.d.ts +24 -0
- package/cli/dist/infra/github/pulls.js +56 -0
- package/cli/dist/infra/github/queries.d.ts +12 -4
- package/cli/dist/infra/github/queries.js +156 -8
- package/cli/dist/infra/github/readout.d.ts +5 -1
- package/cli/dist/infra/github/readout.js +11 -0
- package/cli/dist/infra/github/repos.d.ts +18 -0
- package/cli/dist/infra/github/repos.js +31 -0
- package/cli/dist/infra/nx-scope.d.ts +1 -1
- package/cli/dist/infra/nx-scope.js +1 -1
- package/cli/dist/infra/state-store.d.ts +10 -1
- package/cli/dist/infra/state-store.js +14 -2
- package/cli/dist/infra/worktree-links.d.ts +3 -0
- package/cli/dist/infra/worktree-links.js +8 -1
- package/cli/dist/infra/worktree.d.ts +12 -1
- package/cli/dist/infra/worktree.js +40 -23
- package/cli/dist/mcp/result.d.ts +34 -6
- package/cli/dist/mcp/result.js +62 -18
- package/cli/dist/mcp/server.d.ts +2 -2
- package/cli/dist/mcp/server.js +24 -10
- package/cli/templates/comment/plan.md +14 -0
- package/cli/templates/issue/bug.md +1 -1
- package/cli/templates/issue/task-implement.md +13 -6
- package/cli/templates/issue/task.md +1 -1
- package/cli/templates/workflow/pecot-board-sync.yml +84 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/cli/dist/commands/dependabot.d.ts +0 -3
- package/cli/dist/commands/issue-project.d.ts +0 -3
- package/cli/dist/commands/issue-project.js +0 -176
- package/cli/dist/commands/issue-quick.d.ts +0 -3
- package/cli/dist/commands/issue-quick.js +0 -126
- package/cli/dist/commands/issue-read.d.ts +0 -3
- package/cli/dist/commands/issue-read.js +0 -80
- package/cli/dist/commands/repository.d.ts +0 -5
- package/cli/dist/commands/security.d.ts +0 -3
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- 引数の型は readonly にできない */
|
|
2
|
+
// issue reopen。cli/commands/issue.py の移植。
|
|
3
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { GitHubAPIError } from '../infra/github/errors.js';
|
|
6
|
+
import { defineCommand } from './command-definition.js';
|
|
7
|
+
import { isStatusConfigured, setIssueField } from './issue-board.js';
|
|
8
|
+
import { stopWith, requireActiveConfigPlain } from './command-stop.js';
|
|
9
|
+
import { kindOfFailure } from './failure.js';
|
|
10
|
+
import { connectToProject, exitInvalidStatus, ISSUE_REF_DESCRIPTION, issuePath, notConfiguredMessage, parseIssueReferenceOrExit, runWithExit, VALID_STATUSES, } from './issue-shared.js';
|
|
11
|
+
import { createOutput } from './output.js';
|
|
12
|
+
// Projects V2 の自動化が Issue をもう一度閉じることがあるため、status を設定した後に待つ
|
|
13
|
+
const AUTOMATION_WAIT_MILLISECONDS = 3000;
|
|
14
|
+
// アーカイブの解除、1 回目の reopen、ボードの status の更新。設定できたら自動化を待つ
|
|
15
|
+
async function reopenAndSetStatus(output, client, config, issue, status) {
|
|
16
|
+
const { owner, repository, number } = issue;
|
|
17
|
+
const target = `Issue ${issuePath(owner, repository, number)}`;
|
|
18
|
+
const item = await client.getIssueProjectItem(config.project.id, owner, repository, number);
|
|
19
|
+
// アーカイブ済みの項目はボードの列に出ないので戻す。失敗したら Issue を開かずに止める
|
|
20
|
+
if (item?.isArchived === true) {
|
|
21
|
+
try {
|
|
22
|
+
await client.unarchiveProjectItem(config.project.id, item.id);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (!(error instanceof GitHubAPIError))
|
|
26
|
+
throw error;
|
|
27
|
+
stopWith(output, `could not unarchive ${target} on the board: ${error.message}`, kindOfFailure(error));
|
|
28
|
+
}
|
|
29
|
+
output.done({ verb: 'update', target: `${target} unarchived on the board` });
|
|
30
|
+
}
|
|
31
|
+
await client.reopenIssue(owner, repository, number);
|
|
32
|
+
const itemId = item?.id;
|
|
33
|
+
if (itemId === undefined) {
|
|
34
|
+
output.warning(`${target} is not on the project board`);
|
|
35
|
+
}
|
|
36
|
+
else if (await setIssueField(client, config, itemId, 'workflow', status)) {
|
|
37
|
+
output.done({ verb: 'set', target: `${target} status ${status}` });
|
|
38
|
+
await delay(AUTOMATION_WAIT_MILLISECONDS);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
output.warning(notConfiguredMessage(status));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// 2 回目の reopen(自動化による close への対策)で open を確かめ、--comment があれば理由を投稿する
|
|
45
|
+
async function confirmReopened(output, client, issue, comment) {
|
|
46
|
+
const { owner, repository, number } = issue;
|
|
47
|
+
const target = `Issue ${issuePath(owner, repository, number)}`;
|
|
48
|
+
const result = await client.reopenIssue(owner, repository, number);
|
|
49
|
+
const state = result['state'];
|
|
50
|
+
if (state !== 'open') {
|
|
51
|
+
stopWith(output, `${target} did not become open (state: ${typeof state === 'string' ? state : 'None'})`, 'other');
|
|
52
|
+
}
|
|
53
|
+
output.done({ verb: 'reopen', target });
|
|
54
|
+
if (comment === undefined || comment === '')
|
|
55
|
+
return;
|
|
56
|
+
await client.addIssueComment(owner, repository, number, comment);
|
|
57
|
+
output.done({ verb: 'create', target: `comment on ${issuePath(owner, repository, number)}` });
|
|
58
|
+
}
|
|
59
|
+
// 予行。ボードの項目を読み、書く操作を並べる
|
|
60
|
+
async function planReopen(output, client, config, issue, status, comment) {
|
|
61
|
+
const { owner, repository, number } = issue;
|
|
62
|
+
const target = `Issue ${issuePath(owner, repository, number)}`;
|
|
63
|
+
const item = await client.getIssueProjectItem(config.project.id, owner, repository, number);
|
|
64
|
+
output.planned({ verb: 'reopen', target });
|
|
65
|
+
if (item?.isArchived === true)
|
|
66
|
+
output.planned({ verb: 'update', target: `${target} unarchived on the board` });
|
|
67
|
+
if (item === undefined)
|
|
68
|
+
output.warning(`${target} is not on the project board`);
|
|
69
|
+
else if (isStatusConfigured(config, status))
|
|
70
|
+
output.planned({ verb: 'set', target: `${target} status ${status}` });
|
|
71
|
+
else
|
|
72
|
+
output.warning(notConfiguredMessage(status));
|
|
73
|
+
if (comment !== undefined && comment !== '')
|
|
74
|
+
output.planned({ verb: 'create', target: `comment on ${issuePath(owner, repository, number)}` });
|
|
75
|
+
}
|
|
76
|
+
async function reopenIssue(output, client, config, issue, status, comment) {
|
|
77
|
+
await reopenAndSetStatus(output, client, config, issue, status);
|
|
78
|
+
await confirmReopened(output, client, issue, comment);
|
|
79
|
+
}
|
|
80
|
+
const ISSUE_REOPEN = defineCommand({
|
|
81
|
+
path: ['issue', 'reopen'],
|
|
82
|
+
description: 'Reopen a closed Issue (also sets the status on the board)',
|
|
83
|
+
input: z.object({
|
|
84
|
+
issue_ref: z.string().describe(ISSUE_REF_DESCRIPTION),
|
|
85
|
+
status: z.string().default('ready').describe('Status after reopening (backlog/pending/blocked/ready/active/in_review/archived)'),
|
|
86
|
+
comment: z.string().optional().describe('Reason for reopening (posted as a comment)'),
|
|
87
|
+
dry_run: z.boolean().default(false).describe('Show what would change without writing anything'),
|
|
88
|
+
}),
|
|
89
|
+
positional: ['issue_ref'],
|
|
90
|
+
shortFlags: { status: '-s', comment: '-c', dry_run: '-n' },
|
|
91
|
+
interactive: false,
|
|
92
|
+
run: async (input, io) => {
|
|
93
|
+
const output = createOutput(input.dry_run, io);
|
|
94
|
+
return await runWithExit(async () => {
|
|
95
|
+
const { status, comment } = input;
|
|
96
|
+
if (!VALID_STATUSES.has(status))
|
|
97
|
+
exitInvalidStatus(output, status);
|
|
98
|
+
const config = requireActiveConfigPlain(output);
|
|
99
|
+
const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
|
|
100
|
+
const target = `Issue ${issuePath(owner, repository, number)}`;
|
|
101
|
+
try {
|
|
102
|
+
const client = await connectToProject(output, config, owner, repository);
|
|
103
|
+
const run = input.dry_run ? planReopen : reopenIssue;
|
|
104
|
+
await run(output, client, config, { owner, repository, number }, status, comment);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (!(error instanceof GitHubAPIError))
|
|
108
|
+
throw error;
|
|
109
|
+
stopWith(output, `could not reopen ${target}: ${error.message}`, kindOfFailure(error));
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
export const ISSUE_REOPEN_COMMANDS = [ISSUE_REOPEN];
|
|
115
|
+
//# sourceMappingURL=issue-reopen.js.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { ProjectConfig } from '../domain/config.js';
|
|
3
3
|
import type { IssueFrontmatter } from '../domain/frontmatter.js';
|
|
4
|
+
import type { UsedOrder } from '../domain/issue-order.js';
|
|
4
5
|
import type { IssueReference } from '../domain/reference-parser.js';
|
|
5
6
|
import type { JsonObject } from '../domain/json.js';
|
|
6
7
|
import type { GitHubClient } from '../infra/github/index.js';
|
|
8
|
+
import type { HintedText } from './command-hint.js';
|
|
7
9
|
import type { BoardItem } from './issue-board.js';
|
|
8
10
|
import type { Output } from './output.js';
|
|
9
11
|
export type IssueType = IssueFrontmatter['type'];
|
|
@@ -12,7 +14,7 @@ issue comment のテンプレ検証失敗の終了コード。通信失敗・設
|
|
|
12
14
|
*/
|
|
13
15
|
export declare const COMMENT_VALIDATION_EXIT_CODE = 3;
|
|
14
16
|
/**
|
|
15
|
-
Issue 種別の入力。issue create
|
|
17
|
+
Issue 種別の入力。issue create が使う
|
|
16
18
|
*/
|
|
17
19
|
export declare const ISSUE_TYPE_SCHEMA: z.ZodDefault<z.ZodEnum<{
|
|
18
20
|
bug: "bug";
|
|
@@ -28,14 +30,14 @@ export declare const VALID_STATUSES: ReadonlySet<string>;
|
|
|
28
30
|
*/
|
|
29
31
|
export declare const TYPE_DEFAULT_STATUS: Readonly<Record<IssueType, string>>;
|
|
30
32
|
/**
|
|
31
|
-
Backlog に置く型(
|
|
33
|
+
Backlog に置く型(freeform の size と quick-mode フラグの扱いが Epic と同じ)
|
|
32
34
|
*/
|
|
33
35
|
export declare const BACKLOG_TYPES: ReadonlySet<string>;
|
|
34
36
|
/**
|
|
35
37
|
run の本体を包む。終わったら 0 を返す。BadParameterError は使い方の誤りにして伝える。
|
|
36
38
|
それ以外の例外はそのまま伝える。CommandExit は defineCommand が受けて終了コードにする
|
|
37
39
|
*/
|
|
38
|
-
export declare function runWithExit(body: () => Promise<void>): Promise<
|
|
40
|
+
export declare function runWithExit(body: () => Promise<void>): Promise<0>;
|
|
39
41
|
/**
|
|
40
42
|
`owner/repo/N` の表記。エラー文と done の行の対象に使う
|
|
41
43
|
*/
|
|
@@ -54,10 +56,10 @@ export declare function parseIssueReferenceOrExit(output: Output, repository: st
|
|
|
54
56
|
*/
|
|
55
57
|
export declare function exitInvalidStatus(output: Output, status: string): never;
|
|
56
58
|
/**
|
|
57
|
-
起票時の status
|
|
58
|
-
enum 外の値(`--status foo
|
|
59
|
+
起票時の status が、許す値のどれかと一致するか確かめる。違えば終了コード 1。許す値の既定は、型対応テンプレートの既定値だけ。
|
|
60
|
+
enum 外の値(`--status foo`)と、許さない値(`--type bug --status backlog`)は文を分ける
|
|
59
61
|
*/
|
|
60
|
-
export declare function validateStatusForType(output: Output, issueType: IssueType, status: string): void;
|
|
62
|
+
export declare function validateStatusForType(output: Output, issueType: IssueType, status: string, allowed?: readonly string[]): void;
|
|
61
63
|
/**
|
|
62
64
|
CLI のオプションで来た parent_epic。空・空白だけなら undefined、数字だけなら整数(安全な整数を超えるなら数字の文字列)、それ以外は文字列
|
|
63
65
|
*/
|
|
@@ -86,20 +88,23 @@ export declare function warnEpicRepositoryException(output: Output, resolvedRepo
|
|
|
86
88
|
export interface IssueTitleOptions {
|
|
87
89
|
readonly parentEpic?: number | undefined;
|
|
88
90
|
readonly order?: number | undefined;
|
|
89
|
-
/**
|
|
90
|
-
同じ段の中の枝の文字(a-z)。order が無ければ使わない
|
|
91
|
-
*/
|
|
92
|
-
readonly parallel?: string | undefined;
|
|
93
91
|
}
|
|
94
92
|
/**
|
|
95
|
-
タイトルに接頭辞と、Epic 番号・order
|
|
93
|
+
タイトルに接頭辞と、Epic 番号・order を付ける。例は `[Task] #353-04: タイトル`
|
|
96
94
|
*/
|
|
97
95
|
export declare function buildIssueTitle(issueType: string, title: string, options?: Readonly<IssueTitleOptions>): string;
|
|
98
96
|
/**
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
親 Epic のサブ Issue から、使われた番号を読む。全件を読む。Epic を取れなければ warning を出して undefined
|
|
98
|
+
*/
|
|
99
|
+
export declare function readUsedOrders(output: Output, client: GitHubClient, owner: string, repository: string, parentEpic: number): Promise<readonly UsedOrder[] | undefined>;
|
|
100
|
+
/**
|
|
101
|
+
明示の order が既存の Issue と重なったときの error を出して終了コード 1。一度使った番号は、OPEN でも CLOSED でも再利用できない
|
|
102
|
+
*/
|
|
103
|
+
export declare function stopForDuplicateOrder(output: Output, parentEpic: number, order: number, existing: UsedOrder, nextAvailable: number): never;
|
|
104
|
+
/**
|
|
105
|
+
同じ Epic に、同じ order の Issue が無いことを確かめる。最初の一致を error にして終了コード 1。Epic を取れなければ warning だけで続ける
|
|
101
106
|
*/
|
|
102
|
-
export declare function checkDuplicateOrder(output: Output, client: GitHubClient, owner: string, repository: string, parentEpic: number, order: number
|
|
107
|
+
export declare function checkDuplicateOrder(output: Output, client: GitHubClient, owner: string, repository: string, parentEpic: number, order: number): Promise<void>;
|
|
103
108
|
/**
|
|
104
109
|
Issue を作り、`created:` の行を出して API の応答を返す。失敗は error の行と終了コード 1。
|
|
105
110
|
source は作成元のファイル名(`from <source>` として行の末尾に付く)
|
|
@@ -130,21 +135,29 @@ export interface IssueField {
|
|
|
130
135
|
readonly label: string;
|
|
131
136
|
}
|
|
132
137
|
/**
|
|
133
|
-
カスタムフィールドを順に設定し、設定できた分を 1 行の set
|
|
138
|
+
カスタムフィールドを順に設定し、設定できた分を 1 行の set にする。失敗したフィールドは、何も出さずに飛ばす。設定できたフィールドの名前を返す
|
|
134
139
|
*/
|
|
135
|
-
export declare function setIssueFields(output: Output, client: GitHubClient, config: ProjectConfig, itemId: string, target: string, fields: readonly IssueField[]): Promise<
|
|
140
|
+
export declare function setIssueFields(output: Output, client: GitHubClient, config: ProjectConfig, itemId: string, target: string, fields: readonly IssueField[]): Promise<readonly string[]>;
|
|
136
141
|
/**
|
|
137
|
-
親 Epic のサブ Issue にする。失敗は Issue の URL
|
|
142
|
+
親 Epic のサブ Issue にする。失敗は Issue の URL(issueUrl が undefined なら出し済みとして省く)、error の行の順に出して終了コード 1。issueNodeId は、無ければ取り直す関数
|
|
138
143
|
*/
|
|
139
|
-
export declare function linkToParentEpic(output: Output, client: GitHubClient, target: string, parentReference: IssueReference, issueNodeId: string, issueUrl: string): Promise<void>;
|
|
144
|
+
export declare function linkToParentEpic(output: Output, client: GitHubClient, target: string, parentReference: IssueReference, issueNodeId: string | (() => Promise<string>), issueUrl: string | undefined): Promise<void>;
|
|
140
145
|
/**
|
|
141
146
|
リポジトリがプロジェクトにリンクされていなければ、message を error に出して終了コード 1
|
|
142
147
|
*/
|
|
143
148
|
export declare function ensureRepositoryInProject(output: Output, config: ProjectConfig, client: GitHubClient, owner: string, repository: string, message: string): Promise<void>;
|
|
144
149
|
/**
|
|
150
|
+
クライアントを作り、リポジトリがプロジェクトにあることを確かめる。無ければ error と終了コード 1。board add・board move・issue reopen が使う
|
|
151
|
+
*/
|
|
152
|
+
export declare function connectToProject(output: Output, config: ProjectConfig, owner: string, repository: string): Promise<GitHubClient>;
|
|
153
|
+
/**
|
|
154
|
+
ボードに無い status の error の文。blocked は後から足せる option なので、足し方の hint を添える
|
|
155
|
+
*/
|
|
156
|
+
export declare function notConfiguredMessage(status: string): string | HintedText;
|
|
157
|
+
/**
|
|
145
158
|
起票用のクライアントを作り、リポジトリのリンクと、親 Epic のリポジトリでの order の重複を確かめる
|
|
146
159
|
*/
|
|
147
|
-
export declare function clientForIssueCreate(output: Output, config: ProjectConfig, owner: string, repository: string, display: string, parentReference: IssueReference | undefined, order: number | undefined
|
|
160
|
+
export declare function clientForIssueCreate(output: Output, config: ProjectConfig, owner: string, repository: string, display: string, parentReference: IssueReference | undefined, order: number | undefined): Promise<GitHubClient>;
|
|
148
161
|
/**
|
|
149
162
|
本文をテンプレートと比べ、違反を 1 つの error にして出す。違反があれば true。
|
|
150
163
|
1 行目はテンプレートのパス。続く行に、違反のある種類だけを並べる
|
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { aggregationRepositoryReference, isRepositoryInProject } from '../domain/config.js';
|
|
9
|
+
import { formatHinted } from '../domain/command-hint.js';
|
|
9
10
|
import { BaseError } from '../domain/errors.js';
|
|
10
11
|
import { CommandExit } from './command-definition.js';
|
|
12
|
+
import { planOrders, usedOrdersOf } from '../domain/issue-order.js';
|
|
11
13
|
import { pythonStrip } from '../domain/python-format.js';
|
|
12
14
|
import { issueReferenceToCliReference, parseIssueReference, ReferenceParseError } from '../domain/reference-parser.js';
|
|
13
15
|
import { AmbiguousRepositoryError, createRepositoryReference, resolveRepository } from '../domain/repository-resolver.js';
|
|
@@ -16,16 +18,20 @@ import { gitRunnerFor } from '../infra/git.js';
|
|
|
16
18
|
import { GitHubAPIError } from '../infra/github/errors.js';
|
|
17
19
|
import { requireNumber, requireString } from '../infra/github/payload.js';
|
|
18
20
|
import { readTemplateSections, templateFile } from '../infra/template-store.js';
|
|
21
|
+
import { commandHint, hinted, inputHint, inputNameHint } from './command-hint.js';
|
|
19
22
|
import { stopWith } from './command-stop.js';
|
|
23
|
+
import { kindOfFailure } from './failure.js';
|
|
20
24
|
import { createGitHubClient } from './github-client.js';
|
|
21
25
|
import { addIssueToBoard, createIssue, setIssueField } from './issue-board.js';
|
|
22
26
|
import { USAGE_EXIT_CODE, UsageError } from './usage-error.js';
|
|
27
|
+
// Epic を作るコマンド。作成先の案内に使う
|
|
28
|
+
const EPIC_CREATE_PATH = ['issue', 'create'];
|
|
23
29
|
/**
|
|
24
30
|
issue comment のテンプレ検証失敗の終了コード。通信失敗・設定なし・引数不足の 1 と区別し、hooks がこの値で分岐する
|
|
25
31
|
*/
|
|
26
32
|
export const COMMENT_VALIDATION_EXIT_CODE = 3;
|
|
27
33
|
/**
|
|
28
|
-
Issue 種別の入力。issue create
|
|
34
|
+
Issue 種別の入力。issue create が使う
|
|
29
35
|
*/
|
|
30
36
|
export const ISSUE_TYPE_SCHEMA = z.enum(['task', 'bug', 'epic', 'tracker']).default('task').describe('Issue type (task/bug/epic/tracker)');
|
|
31
37
|
export const PARENT_EPIC_DESCRIPTION = 'Parent Epic reference: an integer (relative to aggregation_repo) or the primary form \'owner/repo/N\'';
|
|
@@ -45,7 +51,7 @@ const TYPE_PREFIX_MAP = new Map([
|
|
|
45
51
|
*/
|
|
46
52
|
export const TYPE_DEFAULT_STATUS = { epic: 'backlog', tracker: 'backlog', task: 'ready', bug: 'ready' };
|
|
47
53
|
/**
|
|
48
|
-
Backlog に置く型(
|
|
54
|
+
Backlog に置く型(freeform の size と quick-mode フラグの扱いが Epic と同じ)
|
|
49
55
|
*/
|
|
50
56
|
export const BACKLOG_TYPES = new Set(['epic', 'tracker']);
|
|
51
57
|
// --- 終了の表し方 ---
|
|
@@ -53,6 +59,12 @@ export const BACKLOG_TYPES = new Set(['epic', 'tracker']);
|
|
|
53
59
|
引数の値が不正。Python の typer.BadParameter。呼ぶ側が受けない場合は、runWithExit が使い方の誤り(終了コード 2)にする
|
|
54
60
|
*/
|
|
55
61
|
class BadParameterError extends BaseError {
|
|
62
|
+
text;
|
|
63
|
+
// message は CLI の形。text は出し先の形で描き直すために持つ
|
|
64
|
+
constructor(text) {
|
|
65
|
+
super(formatHinted(text, 'cli'));
|
|
66
|
+
this.text = text;
|
|
67
|
+
}
|
|
56
68
|
}
|
|
57
69
|
/**
|
|
58
70
|
run の本体を包む。終わったら 0 を返す。BadParameterError は使い方の誤りにして伝える。
|
|
@@ -101,7 +113,7 @@ function parseIssueReferenceFromContext(repository, raw) {
|
|
|
101
113
|
}
|
|
102
114
|
catch (error) {
|
|
103
115
|
if (error instanceof ReferenceParseError)
|
|
104
|
-
throw new BadParameterError(error.message);
|
|
116
|
+
throw new BadParameterError(error.hintedText ?? error.message);
|
|
105
117
|
throw error;
|
|
106
118
|
}
|
|
107
119
|
}
|
|
@@ -115,7 +127,7 @@ export function parseIssueReferenceOrExit(output, repository, raw) {
|
|
|
115
127
|
catch (error) {
|
|
116
128
|
if (!(error instanceof BadParameterError))
|
|
117
129
|
throw error;
|
|
118
|
-
return stopWith(output, error.
|
|
130
|
+
return stopWith(output, error.text, 'invalid-input', USAGE_EXIT_CODE);
|
|
119
131
|
}
|
|
120
132
|
}
|
|
121
133
|
// --- status ---
|
|
@@ -123,20 +135,20 @@ export function parseIssueReferenceOrExit(output, repository, raw) {
|
|
|
123
135
|
不正な status と、有効な値を出して終了コード 1
|
|
124
136
|
*/
|
|
125
137
|
export function exitInvalidStatus(output, status) {
|
|
126
|
-
return stopWith(output, `invalid status: ${status}\nvalid values: backlog/pending/blocked/ready/active/in_review/archived
|
|
138
|
+
return stopWith(output, `invalid status: ${status}\nvalid values: backlog/pending/blocked/ready/active/in_review/archived`, 'invalid-input');
|
|
127
139
|
}
|
|
128
140
|
/**
|
|
129
|
-
起票時の status
|
|
130
|
-
enum 外の値(`--status foo
|
|
141
|
+
起票時の status が、許す値のどれかと一致するか確かめる。違えば終了コード 1。許す値の既定は、型対応テンプレートの既定値だけ。
|
|
142
|
+
enum 外の値(`--status foo`)と、許さない値(`--type bug --status backlog`)は文を分ける
|
|
131
143
|
*/
|
|
132
|
-
export function validateStatusForType(output, issueType, status) {
|
|
144
|
+
export function validateStatusForType(output, issueType, status, allowed) {
|
|
133
145
|
if (!VALID_STATUSES.has(status))
|
|
134
146
|
exitInvalidStatus(output, status);
|
|
135
147
|
// eslint-disable-next-line security/detect-object-injection -- issueType は列挙型
|
|
136
|
-
const
|
|
137
|
-
if (status
|
|
148
|
+
const accepted = allowed ?? [TYPE_DEFAULT_STATUS[issueType]];
|
|
149
|
+
if (accepted.includes(status))
|
|
138
150
|
return;
|
|
139
|
-
stopWith(output, `the status at creation for type '${issueType}' is only '${
|
|
151
|
+
stopWith(output, `the status at creation for type '${issueType}' is only ${accepted.map(value => `'${value}'`).join(' or ')} (given: ${status})\nhint: move it to pending or another status on the board after creation`, 'invalid-input');
|
|
140
152
|
}
|
|
141
153
|
// --- parent_epic・タイトル・order ---
|
|
142
154
|
/**
|
|
@@ -182,7 +194,7 @@ export function resolveEpicTargetRepository(output, repository, config) {
|
|
|
182
194
|
const aggregation = config.aggregation_repo;
|
|
183
195
|
if (explicit === undefined) {
|
|
184
196
|
if (aggregation === undefined) {
|
|
185
|
-
stopWith(output,
|
|
197
|
+
stopWith(output, hinted `cannot decide where to create the Epic\ndeclare aggregation_repo in the project config, or pass ${inputNameHint(EPIC_CREATE_PATH, 'repo')}`, 'repo-setting-missing', USAGE_EXIT_CODE);
|
|
186
198
|
}
|
|
187
199
|
return { repository: aggregation, needsWarning: false };
|
|
188
200
|
}
|
|
@@ -192,83 +204,58 @@ export function resolveEpicTargetRepository(output, repository, config) {
|
|
|
192
204
|
Epic の作成先が aggregation_repo と違うときの警告
|
|
193
205
|
*/
|
|
194
206
|
export function warnEpicRepositoryException(output, resolvedRepository, config) {
|
|
195
|
-
output.warning(
|
|
207
|
+
output.warning(hinted `${inputHint(EPIC_CREATE_PATH, 'repo', resolvedRepository)} differs from aggregation_repo (${String(config.aggregation_repo)})\ncontinuing as an exception for an Epic in an implementation repo`);
|
|
196
208
|
}
|
|
197
209
|
/**
|
|
198
|
-
タイトルに接頭辞と、Epic 番号・order
|
|
210
|
+
タイトルに接頭辞と、Epic 番号・order を付ける。例は `[Task] #353-04: タイトル`
|
|
199
211
|
*/
|
|
200
212
|
export function buildIssueTitle(issueType, title, options = {}) {
|
|
201
213
|
const prefix = TYPE_PREFIX_MAP.get(issueType) ?? '';
|
|
202
214
|
const hasPrefix = prefix !== '' && title.startsWith(prefix);
|
|
203
215
|
const baseTitle = hasPrefix ? pythonStrip(title.slice(prefix.length)) : title;
|
|
204
216
|
if (options.parentEpic !== undefined && options.order !== undefined) {
|
|
205
|
-
const number = `#${String(options.parentEpic)}-${orderLabel(options.order
|
|
217
|
+
const number = `#${String(options.parentEpic)}-${orderLabel(options.order)}`;
|
|
206
218
|
return prefix === '' ? `${number}: ${baseTitle}` : `${prefix} ${number}: ${baseTitle}`;
|
|
207
219
|
}
|
|
208
220
|
return prefix === '' || hasPrefix ? title : `${prefix} ${title}`;
|
|
209
221
|
}
|
|
210
222
|
/**
|
|
211
|
-
|
|
223
|
+
タイトルの番号。2 桁にそろえる
|
|
212
224
|
*/
|
|
213
|
-
function orderLabel(order
|
|
214
|
-
return
|
|
215
|
-
}
|
|
216
|
-
// タイトルの `#123-01:` と `#123-01a:` から、Epic 番号・段・枝を取る
|
|
217
|
-
const ORDER_PATTERN = /#(\d+)-(\d+)([a-z])?:/u;
|
|
218
|
-
const LOWERCASE_LETTERS = Array.from({ length: 26 }, (_, index) => String.fromCodePoint(97 + index));
|
|
219
|
-
function usedOrdersOf(subIssues, parentEpic) {
|
|
220
|
-
const orders = [];
|
|
221
|
-
const values = [];
|
|
222
|
-
for (const sub of subIssues) {
|
|
223
|
-
const [, epic, stage, letter] = ORDER_PATTERN.exec(sub.title) ?? [];
|
|
224
|
-
if (epic === undefined || stage === undefined || Number(epic) !== parentEpic)
|
|
225
|
-
continue;
|
|
226
|
-
values.push(Number(stage));
|
|
227
|
-
orders.push({ ...sub, stage: Number(stage), parallel: letter });
|
|
228
|
-
}
|
|
229
|
-
return { orders, values };
|
|
225
|
+
function orderLabel(order) {
|
|
226
|
+
return String(order).padStart(2, '0');
|
|
230
227
|
}
|
|
231
228
|
/**
|
|
232
|
-
|
|
233
|
-
同じ段では、枝ありと枝なしも重複。最初の一致を error にして終了コード 1。Epic を取れなければ warning だけで続ける
|
|
229
|
+
親 Epic のサブ Issue から、使われた番号を読む。全件を読む。Epic を取れなければ warning を出して undefined
|
|
234
230
|
*/
|
|
235
|
-
export async function
|
|
236
|
-
let subIssues;
|
|
231
|
+
export async function readUsedOrders(output, client, owner, repository, parentEpic) {
|
|
237
232
|
try {
|
|
238
|
-
|
|
239
|
-
subIssues = slim.sub_issues;
|
|
233
|
+
return usedOrdersOf(await client.getAllSubIssues(owner, repository, parentEpic), parentEpic);
|
|
240
234
|
}
|
|
241
235
|
catch (error) {
|
|
242
236
|
if (!(error instanceof GitHubAPIError))
|
|
243
237
|
throw error;
|
|
244
238
|
output.warning(`could not fetch the parent Epic #${String(parentEpic)}: ${error.message}`);
|
|
245
|
-
return;
|
|
239
|
+
return undefined;
|
|
246
240
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
明示の order が既存の Issue と重なったときの error を出して終了コード 1。一度使った番号は、OPEN でも CLOSED でも再利用できない
|
|
244
|
+
*/
|
|
245
|
+
export function stopForDuplicateOrder(output, parentEpic, order, existing, nextAvailable) {
|
|
246
|
+
const stateLabel = existing.state === 'OPEN' ? 'OPEN' : 'CLOSED';
|
|
247
|
+
return stopWith(output, `Epic #${String(parentEpic)} already has an Issue with order=${String(order)} (${stateLabel})\n#${String(existing.number)} ${existing.title}\nnext available order: ${String(nextAvailable)}`, 'order-conflict');
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
同じ Epic に、同じ order の Issue が無いことを確かめる。最初の一致を error にして終了コード 1。Epic を取れなければ warning だけで続ける
|
|
251
|
+
*/
|
|
252
|
+
export async function checkDuplicateOrder(output, client, owner, repository, parentEpic, order) {
|
|
253
|
+
const used = await readUsedOrders(output, client, owner, repository, parentEpic);
|
|
254
|
+
if (used === undefined)
|
|
251
255
|
return;
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
nextOrder += 1;
|
|
256
|
-
let conflict;
|
|
257
|
-
let suggestion;
|
|
258
|
-
if (parallel === undefined && duplicate.parallel === undefined) {
|
|
259
|
-
conflict = `an Issue with order=${String(order)}`;
|
|
260
|
-
suggestion = `next available order: ${String(nextOrder)}`;
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
const usedLetters = new Set(sameOrder.map(sub => sub.parallel));
|
|
264
|
-
const letter = LOWERCASE_LETTERS.find(candidate => !usedLetters.has(candidate));
|
|
265
|
-
suggestion = letter === undefined || usedLetters.has(undefined)
|
|
266
|
-
? `next available order: ${String(Math.max(...usedValues) + 1)}`
|
|
267
|
-
: `next available number: ${orderLabel(order, letter)}`;
|
|
268
|
-
conflict = `an Issue (${orderLabel(order, duplicate.parallel)}) that conflicts with order=${orderLabel(order, parallel)}`;
|
|
269
|
-
}
|
|
270
|
-
const stateLabel = duplicate.state === 'OPEN' ? 'OPEN' : 'CLOSED';
|
|
271
|
-
stopWith(output, `Epic #${String(parentEpic)} already has ${conflict} (${stateLabel})\n#${String(duplicate.number)} ${duplicate.title}\n${suggestion}`);
|
|
256
|
+
const plan = planOrders(used, [{ file: '', order }]);
|
|
257
|
+
if (plan.kind === 'duplicate-existing')
|
|
258
|
+
stopForDuplicateOrder(output, parentEpic, order, plan.existing, plan.nextAvailable);
|
|
272
259
|
}
|
|
273
260
|
// --- Issue の作成・ボード・親 Epic ---
|
|
274
261
|
/**
|
|
@@ -283,7 +270,7 @@ export async function createIssueOrExit(output, client, owner, repository, title
|
|
|
283
270
|
catch (error) {
|
|
284
271
|
if (!(error instanceof GitHubAPIError))
|
|
285
272
|
throw error;
|
|
286
|
-
return stopWith(output, `could not create an Issue in ${owner}/${repository}: ${error.message}
|
|
273
|
+
return stopWith(output, `could not create an Issue in ${owner}/${repository}: ${error.message}`, kindOfFailure(error));
|
|
287
274
|
}
|
|
288
275
|
const target = `Issue ${issuePath(owner, repository, requireNumber(issue['number'], 'number'))}`;
|
|
289
276
|
output.done({ verb: 'create', target: source === undefined || source === '' ? target : `${target} from ${source}` });
|
|
@@ -319,14 +306,17 @@ export async function addToBoardOrWarn(output, client, config, owner, repository
|
|
|
319
306
|
return added;
|
|
320
307
|
}
|
|
321
308
|
/**
|
|
322
|
-
カスタムフィールドを順に設定し、設定できた分を 1 行の set
|
|
309
|
+
カスタムフィールドを順に設定し、設定できた分を 1 行の set にする。失敗したフィールドは、何も出さずに飛ばす。設定できたフィールドの名前を返す
|
|
323
310
|
*/
|
|
324
311
|
export async function setIssueFields(output, client, config, itemId, target, fields) {
|
|
325
312
|
const labels = [];
|
|
313
|
+
const written = [];
|
|
326
314
|
for (const { fieldName, optionName, label } of fields) {
|
|
327
315
|
try {
|
|
328
|
-
if (await setIssueField(client, config, itemId, fieldName, optionName))
|
|
316
|
+
if (await setIssueField(client, config, itemId, fieldName, optionName)) {
|
|
329
317
|
labels.push(label);
|
|
318
|
+
written.push(fieldName);
|
|
319
|
+
}
|
|
330
320
|
}
|
|
331
321
|
catch (error) {
|
|
332
322
|
if (!(error instanceof GitHubAPIError))
|
|
@@ -335,21 +325,23 @@ export async function setIssueFields(output, client, config, itemId, target, fie
|
|
|
335
325
|
}
|
|
336
326
|
if (labels.length > 0)
|
|
337
327
|
output.done({ verb: 'set', target: `${target} ${labels.join(', ')}` });
|
|
328
|
+
return written;
|
|
338
329
|
}
|
|
339
330
|
/**
|
|
340
|
-
親 Epic のサブ Issue にする。失敗は Issue の URL
|
|
331
|
+
親 Epic のサブ Issue にする。失敗は Issue の URL(issueUrl が undefined なら出し済みとして省く)、error の行の順に出して終了コード 1。issueNodeId は、無ければ取り直す関数
|
|
341
332
|
*/
|
|
342
333
|
export async function linkToParentEpic(output, client, target, parentReference, issueNodeId, issueUrl) {
|
|
343
334
|
const parent = issueReferenceToCliReference(parentReference);
|
|
344
335
|
try {
|
|
345
336
|
const parentNodeId = await client.getIssueNodeId(parentReference.repository.owner, parentReference.repository.repository, parentReference.number);
|
|
346
|
-
await client.addSubIssue(parentNodeId, issueNodeId);
|
|
337
|
+
await client.addSubIssue(parentNodeId, typeof issueNodeId === 'string' ? issueNodeId : await issueNodeId());
|
|
347
338
|
}
|
|
348
339
|
catch (error) {
|
|
349
340
|
if (!(error instanceof GitHubAPIError))
|
|
350
341
|
throw error;
|
|
351
|
-
|
|
352
|
-
|
|
342
|
+
if (issueUrl !== undefined)
|
|
343
|
+
output.data(issueUrl);
|
|
344
|
+
stopWith(output, `could not add ${target} as sub-issue of ${parent}: ${error.message}\nthe order in its title is not counted for the next numbering until it is linked to the parent; link it by hand`, kindOfFailure(error));
|
|
353
345
|
}
|
|
354
346
|
output.done({ verb: 'add', target: `${target} as sub-issue of ${parent}` });
|
|
355
347
|
}
|
|
@@ -359,16 +351,31 @@ export async function linkToParentEpic(output, client, target, parentReference,
|
|
|
359
351
|
export async function ensureRepositoryInProject(output, config, client, owner, repository, message) {
|
|
360
352
|
if (await isRepositoryInProject(config, owner, repository, client))
|
|
361
353
|
return;
|
|
362
|
-
stopWith(output, message);
|
|
354
|
+
stopWith(output, message, 'repo-not-in-project');
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
クライアントを作り、リポジトリがプロジェクトにあることを確かめる。無ければ error と終了コード 1。board add・board move・issue reopen が使う
|
|
358
|
+
*/
|
|
359
|
+
export async function connectToProject(output, config, owner, repository) {
|
|
360
|
+
const client = createGitHubClient(output, config.host);
|
|
361
|
+
await ensureRepositoryInProject(output, config, client, owner, repository, `repository ${owner}/${repository} is not in the project`);
|
|
362
|
+
return client;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
ボードに無い status の error の文。blocked は後から足せる option なので、足し方の hint を添える
|
|
366
|
+
*/
|
|
367
|
+
export function notConfiguredMessage(status) {
|
|
368
|
+
const base = `status '${status}' is not configured in the project`;
|
|
369
|
+
return status === 'blocked' ? hinted `${base}\nhint: run ${commandHint(['project', 'init'])} to add the Blocked option to the board` : base;
|
|
363
370
|
}
|
|
364
371
|
/**
|
|
365
372
|
起票用のクライアントを作り、リポジトリのリンクと、親 Epic のリポジトリでの order の重複を確かめる
|
|
366
373
|
*/
|
|
367
|
-
export async function clientForIssueCreate(output, config, owner, repository, display, parentReference, order
|
|
374
|
+
export async function clientForIssueCreate(output, config, owner, repository, display, parentReference, order) {
|
|
368
375
|
const client = createGitHubClient(output, config.host);
|
|
369
376
|
await ensureRepositoryInProject(output, config, client, owner, repository, `${display} is not linked to the project`);
|
|
370
377
|
if (parentReference !== undefined && order !== undefined) {
|
|
371
|
-
await checkDuplicateOrder(output, client, parentReference.repository.owner, parentReference.repository.repository, parentReference.number, order
|
|
378
|
+
await checkDuplicateOrder(output, client, parentReference.repository.owner, parentReference.repository.repository, parentReference.number, order);
|
|
372
379
|
}
|
|
373
380
|
return client;
|
|
374
381
|
}
|
|
@@ -414,6 +421,6 @@ Issue 本文を種別のテンプレートと比べる。違反があれば erro
|
|
|
414
421
|
*/
|
|
415
422
|
export function validateIssueTemplate(output, templateType, body) {
|
|
416
423
|
if (hasReportedTemplateViolations(output, body, templateFile('issue', templateType), { emDashHint: true }))
|
|
417
|
-
throw new CommandExit(1);
|
|
424
|
+
throw new CommandExit(1, 'content-invalid');
|
|
418
425
|
}
|
|
419
426
|
//# sourceMappingURL=issue-shared.js.map
|