@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
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
// project
|
|
1
|
+
// project のグループのコマンド。Python の cli/commands/project.py の移植。
|
|
2
2
|
import { readdirSync, statSync } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { RELEASE_TYPES, findRepository, parsePackage, withAggregationRepository, withRepositoryAppended, withRepositoryReplaced, parseProjectConfig, serializeProjectConfig } from '../domain/config.js';
|
|
6
6
|
import { choosePlacement, insertOption } from '../domain/field-options.js';
|
|
7
|
-
import { formatBoardOutput } from '../domain/format.js';
|
|
8
7
|
import { jsonField, parseJsonText } from '../domain/json.js';
|
|
9
8
|
import { compareStrings, pythonStrip, pythonStringRepr, splitCodePoints, truncateCodePoints } from '../domain/python-format.js';
|
|
10
|
-
import {
|
|
11
|
-
import { InvalidValueError } from '../domain/errors.js';
|
|
9
|
+
import { splitOwnerRepository } from '../domain/repository-resolver.js';
|
|
12
10
|
import { getActiveConfigPath, loadConfig, projectsDirectory, saveConfig } from '../infra/config-store.js';
|
|
13
11
|
import { GitHubAPIError, GitHubNotFoundError } from '../infra/github/errors.js';
|
|
14
12
|
import { asArray, isTruthy, requireNumber, requireString } from '../infra/github/payload.js';
|
|
15
13
|
import { resolveRealPath } from '../infra/paths.js';
|
|
16
14
|
import { hasErrorCode } from '../infra/os-error.js';
|
|
17
15
|
import { CommandExit, defineCommand } from './command-definition.js';
|
|
16
|
+
import { commandHint, hinted, inputHint, inputNameHint, placeholder } from './command-hint.js';
|
|
18
17
|
import { requireActiveConfig, stopWith } from './command-stop.js';
|
|
18
|
+
import { kindOfFailure } from './failure.js';
|
|
19
19
|
import { createGitHubClient } from './github-client.js';
|
|
20
20
|
import { createOutput } from './output.js';
|
|
21
|
-
import { collectAlertStatuses, infoJson, infoMarkdown, pruneArchivedItems, readBoard } from './project-info.js';
|
|
22
21
|
import { BLOCKED_SPEC, NEEDS_ATTENTION_SPEC, PRIORITY_FIELD_OPTIONS, SIZE_FIELD_OPTIONS, STATUS_FIELD_NAME, WORKFLOW_FIELD_OPTIONS, buildRepository, failApi, fieldNodesOf, findProjectByTitle, hasWorkflowField, lastFieldNamed, missingRequiredOptions, stopMissingOptions, syncProjectConfig, textOf, } from './project-sync.js';
|
|
23
22
|
const DEFAULT_HOST = 'github.com';
|
|
23
|
+
const dryRunInput = z.boolean().default(false).describe('Show what would change without writing anything');
|
|
24
24
|
const AGGREGATION_REPOSITORY_PATTERN = /^[\w.-]+\/[\w.-]+$/u;
|
|
25
25
|
const MISSING_PATH_CODES = new Set(['ENOENT', 'ENOTDIR', 'ELOOP']);
|
|
26
26
|
const SEARCH_TITLE_LIMIT = 38;
|
|
@@ -70,7 +70,7 @@ function padEndCodePoints(text, width) {
|
|
|
70
70
|
}
|
|
71
71
|
function requireActiveWithPath(out) {
|
|
72
72
|
const config = requireActiveConfig(out);
|
|
73
|
-
const configPath = getActiveConfigPath() ?? stopWith(out, 'cannot determine the config file path');
|
|
73
|
+
const configPath = getActiveConfigPath() ?? stopWith(out, 'cannot determine the config file path', 'config-invalid');
|
|
74
74
|
return { config, configPath };
|
|
75
75
|
}
|
|
76
76
|
// 保存の前に、設定として読み直せる形かを確かめる(読めなければ ValidationFailure)
|
|
@@ -120,7 +120,7 @@ const searchCommand = defineCommand({
|
|
|
120
120
|
await guarded(out, 'list projects', async () => {
|
|
121
121
|
const projects = await createGitHubClient(out, host).listProjects(owner);
|
|
122
122
|
if (projects.length === 0)
|
|
123
|
-
stopWith(out, `no projects found for ${owner}
|
|
123
|
+
stopWith(out, `no projects found for ${owner}`, 'project-not-found');
|
|
124
124
|
const lines = [`=== Projects of ${owner} (${host}) ===`, '', `${padEndCodePoints('#', 4)} ${padEndCodePoints('Title', SEARCH_TITLE_WIDTH)} URL`, '-'.repeat(80)];
|
|
125
125
|
for (const project of projects) {
|
|
126
126
|
const number = project['number'] === undefined ? '?' : textOf(project['number']);
|
|
@@ -146,15 +146,22 @@ function optionInputsOf(field) {
|
|
|
146
146
|
};
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
|
-
// 既にあるフィールドに選択肢を 1
|
|
150
|
-
async function addFieldOption(out, client, field, spec) {
|
|
149
|
+
// 既にあるフィールドに選択肢を 1 つ足す。足した(予行では、足す予定の)数(0 か 1)を返す
|
|
150
|
+
async function addFieldOption(out, client, field, spec, isDryRun) {
|
|
151
151
|
const { option } = spec;
|
|
152
152
|
const fieldName = textOf(field['name']);
|
|
153
153
|
const existing = optionInputsOf(field);
|
|
154
154
|
const merged = insertOption(existing, option, choosePlacement(existing, spec.placement ?? [{ end: true }]));
|
|
155
155
|
if (merged === undefined) {
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
const unchanged = { verb: 'unchanged', target: `option ${option.name} in field ${fieldName}` };
|
|
157
|
+
out.planned(unchanged);
|
|
158
|
+
out.done(unchanged);
|
|
159
|
+
return 0;
|
|
160
|
+
}
|
|
161
|
+
const added = { verb: 'add', target: `option ${option.name} to field ${fieldName}` };
|
|
162
|
+
if (isDryRun) {
|
|
163
|
+
out.planned(added);
|
|
164
|
+
return 1;
|
|
158
165
|
}
|
|
159
166
|
try {
|
|
160
167
|
await client.updateProjectFieldOptions(requireString(field['id'], 'field.id'), merged);
|
|
@@ -164,29 +171,36 @@ async function addFieldOption(out, client, field, spec) {
|
|
|
164
171
|
throw error;
|
|
165
172
|
// 選択肢の id を拒む GHES などで足せなくても、作ったフィールドと設定ファイルの同期は進める
|
|
166
173
|
out.warning(`could not add option ${option.name} to field ${fieldName}: ${error.message}`);
|
|
167
|
-
return;
|
|
174
|
+
return 0;
|
|
168
175
|
}
|
|
169
|
-
out.done(
|
|
176
|
+
out.done(added);
|
|
177
|
+
return 1;
|
|
170
178
|
}
|
|
171
179
|
// 既にあるフィールドに足す選択肢。fields は作る前の状態なので、作ったばかりの進行の欄は「無い」扱いで何も出さない(created の行が出ている)
|
|
172
|
-
|
|
180
|
+
// 足した(予行では、足す予定の)選択肢の数を返す
|
|
181
|
+
async function addMissingOptions(out, client, fields, workflowFieldName, isDryRun) {
|
|
173
182
|
const workflowField = lastFieldNamed(fields, workflowFieldName);
|
|
174
|
-
|
|
175
|
-
await addFieldOption(out, client, workflowField, BLOCKED_SPEC);
|
|
183
|
+
const blocked = workflowField === undefined ? 0 : await addFieldOption(out, client, workflowField, BLOCKED_SPEC, isDryRun);
|
|
176
184
|
const statusField = lastFieldNamed(fields, STATUS_FIELD_NAME);
|
|
177
|
-
if (statusField === undefined)
|
|
178
|
-
out
|
|
179
|
-
|
|
180
|
-
|
|
185
|
+
if (statusField === undefined) {
|
|
186
|
+
skipped(out, `field ${STATUS_FIELD_NAME} (not found)`);
|
|
187
|
+
return blocked;
|
|
188
|
+
}
|
|
189
|
+
return blocked + await addFieldOption(out, client, statusField, NEEDS_ATTENTION_SPEC, isDryRun);
|
|
190
|
+
}
|
|
191
|
+
function skipped(out, target) {
|
|
192
|
+
out.planned({ verb: 'skip', target });
|
|
193
|
+
out.done({ verb: 'skip', target });
|
|
181
194
|
}
|
|
182
|
-
//
|
|
183
|
-
|
|
195
|
+
// フィールドを作り、既にあるフィールドには足りない選択肢を足す。既にある進行の欄の必須の値が欠けていれば、何も書かずに止める。
|
|
196
|
+
// 作る・足す(予行では、その予定の)フィールドと選択肢の数を返す
|
|
197
|
+
async function initializeFields(out, client, target, isDryRun) {
|
|
184
198
|
const { owner, name, suffix } = target;
|
|
185
199
|
const project = await findProjectByTitle(out, client, owner, name);
|
|
186
200
|
const projectId = requireString(project['id'], 'project.id');
|
|
187
201
|
const projectInfo = await client.getProjectFields(owner, requireNumber(project['number'], 'project.number'));
|
|
188
202
|
if (projectInfo === undefined || !isTruthy(projectInfo))
|
|
189
|
-
stopWith(out, `could not read project fields: ${name}
|
|
203
|
+
stopWith(out, `could not read project fields: ${name}`, 'not-initialized');
|
|
190
204
|
const fields = fieldNodesOf(projectInfo);
|
|
191
205
|
const workflowFieldName = `pecot-workflow-${suffix}`;
|
|
192
206
|
const existingWorkflow = lastFieldNamed(fields, workflowFieldName);
|
|
@@ -200,15 +214,21 @@ async function initializeFields(out, client, target) {
|
|
|
200
214
|
['pecot-priority', PRIORITY_FIELD_OPTIONS],
|
|
201
215
|
['pecot-size', SIZE_FIELD_OPTIONS],
|
|
202
216
|
];
|
|
217
|
+
let newFieldCount = 0;
|
|
203
218
|
for (const [fieldName, options] of wanted) {
|
|
204
219
|
if (fields.some(field => jsonField(field, 'name') === fieldName)) {
|
|
205
|
-
out
|
|
220
|
+
skipped(out, `field ${fieldName} (already exists)`);
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
newFieldCount += 1;
|
|
224
|
+
if (isDryRun) {
|
|
225
|
+
out.planned({ verb: 'create', target: `field ${fieldName}` });
|
|
206
226
|
continue;
|
|
207
227
|
}
|
|
208
228
|
const created = await client.createProjectField(projectId, fieldName, options);
|
|
209
229
|
out.done({ verb: 'create', target: `field ${fieldName} (ID: ${requireString(created['id'], 'field.id')})` });
|
|
210
230
|
}
|
|
211
|
-
await addMissingOptions(out, client, fields, workflowFieldName);
|
|
231
|
+
return newFieldCount + await addMissingOptions(out, client, fields, workflowFieldName, isDryRun);
|
|
212
232
|
}
|
|
213
233
|
const initCommand = defineCommand({
|
|
214
234
|
path: ['project', 'init'],
|
|
@@ -218,19 +238,21 @@ const initCommand = defineCommand({
|
|
|
218
238
|
name: z.string().describe('Project title'),
|
|
219
239
|
host: z.string().default(DEFAULT_HOST).describe('GitHub host'),
|
|
220
240
|
suffix: z.string().describe('Suffix of the workflow field'),
|
|
241
|
+
dry_run: dryRunInput,
|
|
221
242
|
}),
|
|
222
243
|
positional: ['owner', 'name'],
|
|
223
|
-
shortFlags: { host: '-h', suffix: '-s' },
|
|
244
|
+
shortFlags: { host: '-h', suffix: '-s', dry_run: '-n' },
|
|
224
245
|
interactive: false,
|
|
225
246
|
run: async (input, io) => {
|
|
226
|
-
const out = createOutput(
|
|
247
|
+
const out = createOutput(input.dry_run, io);
|
|
227
248
|
const { owner, name, host, suffix } = input;
|
|
228
249
|
const client = createGitHubClient(out, host);
|
|
229
|
-
await guarded(out, 'initialize project fields', async () =>
|
|
230
|
-
|
|
231
|
-
|
|
250
|
+
const changeCount = await guarded(out, 'initialize project fields', async () => await initializeFields(out, client, input, input.dry_run));
|
|
251
|
+
// 設定ファイルは作るフィールドと選択肢の ID を書くので、予行では作る前の設定を出さない
|
|
252
|
+
if (changeCount > 0 && input.dry_run)
|
|
253
|
+
return 0;
|
|
232
254
|
await guarded(out, 'sync project config', async () => {
|
|
233
|
-
await syncProjectConfig(out, client, { owner, name, host, suffix, skipIfUnchanged: true });
|
|
255
|
+
await syncProjectConfig(out, client, { owner, name, host, suffix, skipIfUnchanged: true, isDryRun: input.dry_run });
|
|
234
256
|
});
|
|
235
257
|
return 0;
|
|
236
258
|
},
|
|
@@ -244,12 +266,13 @@ const projectCreationCommand = defineCommand({
|
|
|
244
266
|
title: z.string().describe('Project title'),
|
|
245
267
|
host: z.string().default(DEFAULT_HOST).describe('GitHub host'),
|
|
246
268
|
suffix: z.string().describe('Suffix of the workflow field'),
|
|
269
|
+
dry_run: dryRunInput,
|
|
247
270
|
}),
|
|
248
271
|
positional: ['owner', 'title'],
|
|
249
|
-
shortFlags: { host: '-h', suffix: '-s' },
|
|
272
|
+
shortFlags: { host: '-h', suffix: '-s', dry_run: '-n' },
|
|
250
273
|
interactive: false,
|
|
251
274
|
run: async (input, io) => {
|
|
252
|
-
const out = createOutput(
|
|
275
|
+
const out = createOutput(input.dry_run, io);
|
|
253
276
|
const { owner, title, host, suffix } = input;
|
|
254
277
|
await guarded(out, 'create project', async () => {
|
|
255
278
|
const client = createGitHubClient(out, host);
|
|
@@ -259,17 +282,22 @@ const projectCreationCommand = defineCommand({
|
|
|
259
282
|
}
|
|
260
283
|
catch (error) {
|
|
261
284
|
if (error instanceof GitHubNotFoundError)
|
|
262
|
-
stopWith(out, `owner not found: ${owner}
|
|
285
|
+
stopWith(out, `owner not found: ${owner}`, 'github-not-found');
|
|
263
286
|
throw error;
|
|
264
287
|
}
|
|
265
288
|
const owned = await client.listProjects(owner);
|
|
266
289
|
const existing = owned.find(project => jsonField(project, 'title') === title);
|
|
267
290
|
if (existing !== undefined)
|
|
268
|
-
stopWith(out, `project already exists: ${title}\nurl: ${textOf(existing['url'])}
|
|
291
|
+
stopWith(out, `project already exists: ${title}\nurl: ${textOf(existing['url'])}`, 'already-exists');
|
|
292
|
+
// フィールドと設定ファイルは作ったプロジェクトの ID を使うので、予行ではプロジェクトの行だけ出す
|
|
293
|
+
if (input.dry_run) {
|
|
294
|
+
out.planned({ verb: 'create', target: `project ${title} for ${owner}` });
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
269
297
|
const created = await client.createProject(ownerId, title);
|
|
270
298
|
out.done({ verb: 'create', target: `project #${textOf(created['number'])} ${textOf(created['url'])}` });
|
|
271
299
|
await guarded(out, 'initialize project fields', async () => {
|
|
272
|
-
await initializeFields(out, client, { owner, name: title, suffix });
|
|
300
|
+
await initializeFields(out, client, { owner, name: title, suffix }, false);
|
|
273
301
|
});
|
|
274
302
|
await guarded(out, 'sync project config', async () => {
|
|
275
303
|
await syncProjectConfig(out, client, { owner, name: title, host, suffix });
|
|
@@ -286,7 +314,7 @@ function findConfigFileArgument(project) {
|
|
|
286
314
|
const named = path.join(projectsDirectory(), project.endsWith('.json') ? project : `${project}.json`);
|
|
287
315
|
return isFile(named) ? named : undefined;
|
|
288
316
|
}
|
|
289
|
-
async function activateFromConfigFile(out, configPath, host) {
|
|
317
|
+
async function activateFromConfigFile(out, configPath, host, isDryRun) {
|
|
290
318
|
let config;
|
|
291
319
|
try {
|
|
292
320
|
config = loadConfig(configPath);
|
|
@@ -295,20 +323,20 @@ async function activateFromConfigFile(out, configPath, host) {
|
|
|
295
323
|
// Python の `except Exception` と同じ範囲(あらゆる Error)で捕まえる
|
|
296
324
|
if (!(error instanceof Error) || error instanceof CommandExit)
|
|
297
325
|
throw error;
|
|
298
|
-
return stopWith(out, `could not load config file ${path.basename(configPath)}: ${error.message}
|
|
326
|
+
return stopWith(out, `could not load config file ${path.basename(configPath)}: ${error.message}`, 'config-invalid');
|
|
299
327
|
}
|
|
300
328
|
await guarded(out, 'sync project', async () => {
|
|
301
329
|
if (host !== undefined && config.host !== host) {
|
|
302
|
-
out.warning(
|
|
330
|
+
out.warning(hinted `${inputHint(ACTIVATE_PATH, 'host', host)} differs from the config file host (${config.host})\nusing the config file host`);
|
|
303
331
|
}
|
|
304
332
|
const client = createGitHubClient(out, config.host);
|
|
305
333
|
const projectInfo = await client.getProjectFields(config.owner, config.project.number);
|
|
306
334
|
if (projectInfo === undefined || !isTruthy(projectInfo))
|
|
307
|
-
stopWith(out, `project #${String(config.project.number)} not found
|
|
335
|
+
stopWith(out, `project #${String(config.project.number)} not found`, 'project-not-found');
|
|
308
336
|
const title = projectInfo['title'];
|
|
309
337
|
if (typeof title !== 'string' || title === '')
|
|
310
|
-
stopWith(out, `could not read the title of project #${String(config.project.number)}
|
|
311
|
-
await syncProjectConfig(out, client, { owner: config.owner, name: title, host: config.host });
|
|
338
|
+
stopWith(out, `could not read the title of project #${String(config.project.number)}`, 'project-not-found');
|
|
339
|
+
await syncProjectConfig(out, client, { owner: config.owner, name: title, host: config.host, isDryRun });
|
|
312
340
|
});
|
|
313
341
|
}
|
|
314
342
|
async function resolveActivationOwner(out, client, owner) {
|
|
@@ -320,10 +348,10 @@ async function resolveActivationOwner(out, client, owner) {
|
|
|
320
348
|
}
|
|
321
349
|
catch (error) {
|
|
322
350
|
if (error instanceof GitHubAPIError)
|
|
323
|
-
return stopWith(out, `could not read the authenticated user: ${error.message}\npass
|
|
351
|
+
return stopWith(out, hinted `could not read the authenticated user: ${error.message}\npass ${inputNameHint(ACTIVATE_PATH, 'owner')} to give the owner explicitly`, kindOfFailure(error));
|
|
324
352
|
throw error;
|
|
325
353
|
}
|
|
326
|
-
return typeof login === 'string' && login !== '' ? login : stopWith(out, 'could not read the authenticated user');
|
|
354
|
+
return typeof login === 'string' && login !== '' ? login : stopWith(out, 'could not read the authenticated user', 'github-api');
|
|
327
355
|
}
|
|
328
356
|
// 一覧の表示モード。初期化済みのプロジェクトに [ACTIVE] を付ける
|
|
329
357
|
async function echoInitializedProjects(out, client, host, owner) {
|
|
@@ -372,21 +400,23 @@ function activeProjectNumber(host, owner) {
|
|
|
372
400
|
async function fetchProjectInfoByReference(out, client, owner, project) {
|
|
373
401
|
if (/^\d+$/u.test(project)) {
|
|
374
402
|
const number = Number(project);
|
|
375
|
-
return await client.getProjectFields(owner, number) ?? stopWith(out, `project #${String(number)} not found
|
|
403
|
+
return await client.getProjectFields(owner, number) ?? stopWith(out, `project #${String(number)} not found`, 'project-not-found');
|
|
376
404
|
}
|
|
377
405
|
const found = await findProjectByTitle(out, client, owner, project);
|
|
378
406
|
const info = await client.getProjectFields(owner, requireNumber(found['number'], 'project.number'));
|
|
379
|
-
return info !== undefined && isTruthy(info) ? info : stopWith(out, `could not read project fields: ${project}
|
|
407
|
+
return info !== undefined && isTruthy(info) ? info : stopWith(out, `could not read project fields: ${project}`, 'not-initialized');
|
|
380
408
|
}
|
|
381
409
|
async function activateByReference(out, client, target) {
|
|
382
|
-
const { host, owner, project } = target;
|
|
410
|
+
const { host, owner, project, isDryRun } = target;
|
|
383
411
|
const info = await fetchProjectInfoByReference(out, client, owner, project);
|
|
384
412
|
const title = textOf(info['title'] ?? '');
|
|
385
413
|
if (!hasWorkflowField(asArray(jsonField(info['fields'], 'nodes')))) {
|
|
386
|
-
stopWith(out, `project "${title}" is not initialized\nrun:
|
|
414
|
+
stopWith(out, hinted `project "${title}" is not initialized\nrun: ${commandHint(['project', 'init'], { owner, name: title, host, suffix: placeholder('suffix') })}`, 'not-initialized');
|
|
387
415
|
}
|
|
388
|
-
await syncProjectConfig(out, client, { owner, name: title, host });
|
|
416
|
+
await syncProjectConfig(out, client, { owner, name: title, host, isDryRun });
|
|
389
417
|
}
|
|
418
|
+
const ACTIVATE_PATH = ['project', 'activate'];
|
|
419
|
+
const LINK_PATH = ['project', 'link'];
|
|
390
420
|
const activateCommand = defineCommand({
|
|
391
421
|
path: ['project', 'activate'],
|
|
392
422
|
description: 'Activate an initialized project',
|
|
@@ -394,103 +424,60 @@ const activateCommand = defineCommand({
|
|
|
394
424
|
project: z.string().optional().describe('Project number or name, or config file path/file name'),
|
|
395
425
|
owner: z.string().optional().describe('Project owner (defaults to the authenticated user)'),
|
|
396
426
|
host: z.string().optional().describe('GitHub host'),
|
|
427
|
+
dry_run: dryRunInput,
|
|
397
428
|
}),
|
|
398
429
|
positional: ['project'],
|
|
399
|
-
shortFlags: { owner: '-o', host: '-h' },
|
|
430
|
+
shortFlags: { owner: '-o', host: '-h', dry_run: '-n' },
|
|
400
431
|
interactive: false,
|
|
401
432
|
run: async (input, io) => {
|
|
402
|
-
const out = createOutput(
|
|
433
|
+
const out = createOutput(input.dry_run, io);
|
|
403
434
|
const { project, host } = input;
|
|
404
435
|
// --host の要らない形(設定ファイルのパスか名前)を先に見る
|
|
405
436
|
const configPath = project === undefined ? undefined : findConfigFileArgument(project);
|
|
406
437
|
if (configPath !== undefined) {
|
|
407
|
-
await activateFromConfigFile(out, configPath, host);
|
|
438
|
+
await activateFromConfigFile(out, configPath, host, input.dry_run);
|
|
408
439
|
return 0;
|
|
409
440
|
}
|
|
410
441
|
await guarded(out, 'activate project', async () => {
|
|
411
442
|
if (host === undefined) {
|
|
412
|
-
stopWith(out, '
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
443
|
+
stopWith(out, hinted `${inputNameHint(ACTIVATE_PATH, 'host')} is required
|
|
444
|
+
example: ${commandHint(ACTIVATE_PATH, { host: 'github.com', owner: 'example-org' })}
|
|
445
|
+
example: ${commandHint(ACTIVATE_PATH, { host: 'ghes.example.com', owner: 'example-org' })}
|
|
446
|
+
example: ${commandHint(ACTIVATE_PATH, { project: 'ghes.example.com_example-org_example-project_example-org' })}`, 'invalid-input');
|
|
416
447
|
}
|
|
417
448
|
const client = createGitHubClient(out, host);
|
|
418
449
|
const owner = await resolveActivationOwner(out, client, input.owner);
|
|
419
450
|
if (project === undefined)
|
|
420
451
|
await echoInitializedProjects(out, client, host, owner);
|
|
421
452
|
else
|
|
422
|
-
await activateByReference(out, client, { host, owner, project });
|
|
453
|
+
await activateByReference(out, client, { host, owner, project, isDryRun: input.dry_run });
|
|
423
454
|
});
|
|
424
455
|
return 0;
|
|
425
456
|
},
|
|
426
457
|
});
|
|
427
|
-
// project
|
|
428
|
-
const infoCommand = defineCommand({
|
|
429
|
-
path: ['project', 'info'],
|
|
430
|
-
description: 'Show the project info dashboard',
|
|
431
|
-
input: z.strictObject({
|
|
432
|
-
json: z.boolean().default(false).describe('Output as JSON'),
|
|
433
|
-
repo: z.string().superRefine((value, context) => {
|
|
434
|
-
try {
|
|
435
|
-
parseOwnerRepository(value);
|
|
436
|
-
}
|
|
437
|
-
catch (error) {
|
|
438
|
-
if (!(error instanceof InvalidValueError))
|
|
439
|
-
throw error;
|
|
440
|
-
context.addIssue({ code: 'custom', message: `must be in 'owner/repo' form: ${error.message}` });
|
|
441
|
-
}
|
|
442
|
-
}).optional().describe('Target repository, given explicitly as \'owner/repo\''),
|
|
443
|
-
}),
|
|
444
|
-
hasOwnRepo: true,
|
|
445
|
-
positional: [],
|
|
446
|
-
shortFlags: { json: '-j' },
|
|
447
|
-
interactive: false,
|
|
448
|
-
run: async (input, io) => {
|
|
449
|
-
const out = createOutput(false, io);
|
|
450
|
-
const config = requireActiveConfig(out);
|
|
451
|
-
const configPath = getActiveConfigPath();
|
|
452
|
-
const projectName = configPath === undefined ? `${config.host}_${config.owner}_${String(config.project.number)}` : path.parse(configPath).name;
|
|
453
|
-
try {
|
|
454
|
-
const client = createGitHubClient(out, config.host);
|
|
455
|
-
const { allItems, items } = await readBoard(client, config, input.repo);
|
|
456
|
-
const statuses = await collectAlertStatuses(client, config);
|
|
457
|
-
await pruneArchivedItems(out, client, config, allItems);
|
|
458
|
-
const view = { config, projectName, statuses };
|
|
459
|
-
out.data(input.json ? infoJson(view, items) : infoMarkdown(view, input.repo, formatBoardOutput(items)));
|
|
460
|
-
}
|
|
461
|
-
catch (error) {
|
|
462
|
-
if (error instanceof GitHubAPIError)
|
|
463
|
-
return failApi(out, 'read project board', error);
|
|
464
|
-
// Python の `except Exception` と同じ範囲(あらゆる Error)で捕まえる
|
|
465
|
-
if (error instanceof Error && !(error instanceof CommandExit))
|
|
466
|
-
return stopWith(out, `unexpected error: ${error.message}`);
|
|
467
|
-
throw error;
|
|
468
|
-
}
|
|
469
|
-
return 0;
|
|
470
|
-
},
|
|
471
|
-
});
|
|
472
|
-
// project set-repo
|
|
458
|
+
// project link
|
|
473
459
|
const packageList = z.array(z.string());
|
|
474
460
|
function parsePackages(out, input) {
|
|
475
461
|
const specs = input.package;
|
|
476
462
|
if (specs === undefined || specs.length === 0)
|
|
477
463
|
return undefined;
|
|
464
|
+
const packageFlag = inputNameHint(LINK_PATH, 'package');
|
|
478
465
|
if (input.changelog_file !== undefined)
|
|
479
|
-
stopWith(out,
|
|
466
|
+
stopWith(out, hinted `${packageFlag} and ${inputNameHint(LINK_PATH, 'changelog_file')} cannot be used together`, 'invalid-input');
|
|
480
467
|
if (input.clear_packages)
|
|
481
|
-
stopWith(out,
|
|
468
|
+
stopWith(out, hinted `${packageFlag} and ${inputHint(LINK_PATH, 'clear_packages')} cannot be used together`, 'invalid-input');
|
|
482
469
|
const parsed = [];
|
|
483
470
|
const seen = new Set();
|
|
484
471
|
for (const spec of specs) {
|
|
485
472
|
const separator = spec.indexOf(':');
|
|
486
473
|
if (separator === -1)
|
|
487
|
-
stopWith(out, `give
|
|
474
|
+
stopWith(out, hinted `give ${inputHint(LINK_PATH, 'package', placeholder('NAME:PATH'))}: ${pythonStringRepr(spec)}`, 'invalid-input');
|
|
488
475
|
const name = pythonStrip(spec.slice(0, separator));
|
|
489
476
|
const changelog = pythonStrip(spec.slice(separator + 1));
|
|
490
477
|
if (name === '' || changelog === '')
|
|
491
|
-
stopWith(out,
|
|
478
|
+
stopWith(out, hinted `${packageFlag} NAME and PATH must not be empty: ${pythonStringRepr(spec)}`, 'invalid-input');
|
|
492
479
|
if (seen.has(name))
|
|
493
|
-
stopWith(out,
|
|
480
|
+
stopWith(out, hinted `${packageFlag} NAME is duplicated: ${pythonStringRepr(name)}`, 'invalid-input');
|
|
494
481
|
seen.add(name);
|
|
495
482
|
// Python も Package(...) の作成で NAME の形を確かめるので、設定を読む前に止まる
|
|
496
483
|
parsed.push(parsePackage({ name, changelog }));
|
|
@@ -510,7 +497,7 @@ function updatedRepository(out, existing, edit) {
|
|
|
510
497
|
}
|
|
511
498
|
if (edit.changelog_file !== undefined) {
|
|
512
499
|
if (packages !== undefined && packages.length > 0) {
|
|
513
|
-
stopWith(out,
|
|
500
|
+
stopWith(out, hinted `this repository has packages set\nrun with ${inputHint(['project', 'link'], 'clear_packages')} before switching to ${inputNameHint(['project', 'link'], 'changelog_file')}`, 'invalid-input');
|
|
514
501
|
}
|
|
515
502
|
changelogFile = edit.changelog_file;
|
|
516
503
|
}
|
|
@@ -537,47 +524,65 @@ async function linkRepository(out, config, repositoryOwner, repositoryName) {
|
|
|
537
524
|
throw error;
|
|
538
525
|
}
|
|
539
526
|
}
|
|
540
|
-
|
|
541
|
-
|
|
527
|
+
// 予行。リンクの有無を読むだけで、リンクしない
|
|
528
|
+
async function plannedLink(out, config, repositoryOwner, repositoryName) {
|
|
529
|
+
try {
|
|
530
|
+
const linked = await createGitHubClient(out, config.host).getLinkedRepositories(config.owner, config.project.number);
|
|
531
|
+
const isLinked = linked.some(entry => entry.owner === repositoryOwner && entry.name === repositoryName);
|
|
532
|
+
return { status: isLinked ? 'already_linked' : 'linked', detail: '' };
|
|
533
|
+
}
|
|
534
|
+
catch (error) {
|
|
535
|
+
if (error instanceof GitHubAPIError)
|
|
536
|
+
return { status: 'failed', detail: error.message };
|
|
537
|
+
throw error;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
const projectLinkCommand = defineCommand({
|
|
541
|
+
path: ['project', 'link'],
|
|
542
|
+
hasOwnRepo: true,
|
|
543
|
+
ignoresGlobalRepo: true,
|
|
542
544
|
description: 'Add or update a repository in the project config',
|
|
543
545
|
input: z.strictObject({
|
|
544
|
-
|
|
546
|
+
repo: z.string().describe('Repository name in owner/repo form'),
|
|
545
547
|
develop_branch: z.string().optional().describe('Development branch name'),
|
|
546
548
|
release_branch: z.string().optional().describe('Release branch name'),
|
|
547
549
|
changelog_file: z.string().optional().describe('CHANGELOG file name'),
|
|
548
550
|
package: packageList.optional().describe('Register a monorepo package as NAME:PATH. Can be repeated. Example: --package pecot:plugins/pecot-workflow/CHANGELOG.md'),
|
|
549
551
|
clear_packages: z.boolean().default(false).describe('Clear the existing packages setting. After clearing, the CHANGELOG falls back to --changelog-file or the default CHANGELOG.md'),
|
|
550
552
|
release_type: z.string().optional().describe('Declare the release method explicitly; the w-release skill picks its procedure from it. single (1 CHANGELOG) / multi (packages) / nx (Nx Release). When omitted, it is inferred from the packages (with packages: multi, without: single)'),
|
|
553
|
+
dry_run: dryRunInput,
|
|
551
554
|
}),
|
|
552
|
-
positional: ['
|
|
553
|
-
shortFlags: { develop_branch: '-b' },
|
|
555
|
+
positional: ['repo'],
|
|
556
|
+
shortFlags: { develop_branch: '-b', dry_run: '-n' },
|
|
554
557
|
interactive: false,
|
|
555
558
|
run: async (input, io) => {
|
|
556
|
-
const out = createOutput(
|
|
559
|
+
const out = createOutput(input.dry_run, io);
|
|
557
560
|
if (input.release_type !== undefined && toReleaseType(input.release_type) === undefined) {
|
|
558
561
|
// Python は sorted() の順(multi, nx, single)で見せる
|
|
559
|
-
stopWith(out,
|
|
562
|
+
stopWith(out, hinted `${inputNameHint(LINK_PATH, 'release_type')} must be one of [${RELEASE_TYPES.toSorted(compareStrings).map(type => pythonStringRepr(type)).join(', ')}] (got: ${pythonStringRepr(input.release_type)})`, 'invalid-input');
|
|
560
563
|
}
|
|
561
564
|
const packages = parsePackages(out, input);
|
|
562
565
|
const { config, configPath } = requireActiveWithPath(out);
|
|
563
|
-
const parts = splitOwnerRepository(input.
|
|
566
|
+
const parts = splitOwnerRepository(input.repo);
|
|
564
567
|
if (parts === undefined)
|
|
565
|
-
stopWith(out,
|
|
568
|
+
stopWith(out, hinted `give the repository as owner/repo\nexample: ${commandHint(['project', 'link'], { repo: 'example-org/my-repo' })}`, 'invalid-input');
|
|
566
569
|
const { owner, repository: name } = parts;
|
|
567
570
|
if (owner !== config.owner) {
|
|
568
|
-
stopWith(out, `repository owner ${owner} differs from project owner ${config.owner}\nGitHub Projects V2 links only repositories of the project owner
|
|
571
|
+
stopWith(out, `repository owner ${owner} differs from project owner ${config.owner}\nGitHub Projects V2 links only repositories of the project owner`, 'invalid-input');
|
|
569
572
|
}
|
|
570
573
|
const existing = findRepository(config, owner, name);
|
|
571
574
|
let next;
|
|
572
575
|
let saved;
|
|
573
576
|
if (existing === undefined) {
|
|
574
|
-
const outcome = await linkRepository(out, config, owner, name);
|
|
575
577
|
const projectNumber = String(config.project.number);
|
|
578
|
+
const outcome = input.dry_run ? await plannedLink(out, config, owner, name) : await linkRepository(out, config, owner, name);
|
|
576
579
|
if (outcome.status === 'failed')
|
|
577
|
-
stopWith(out, `could not link ${input.
|
|
578
|
-
|
|
579
|
-
? { verb: 'unchanged', target: `${input.
|
|
580
|
-
: { verb: 'add', target: `${input.
|
|
580
|
+
stopWith(out, `could not link ${input.repo} to project #${projectNumber}: ${outcome.detail}`, 'github-api');
|
|
581
|
+
const linked = outcome.status === 'already_linked'
|
|
582
|
+
? { verb: 'unchanged', target: `${input.repo} in project #${projectNumber}` }
|
|
583
|
+
: { verb: 'add', target: `${input.repo} to project #${projectNumber}` };
|
|
584
|
+
out.planned(linked);
|
|
585
|
+
out.done(linked);
|
|
581
586
|
next = withRepositoryAppended(config, buildRepository({
|
|
582
587
|
owner,
|
|
583
588
|
name,
|
|
@@ -593,85 +598,117 @@ const repositorySettingCommand = defineCommand({
|
|
|
593
598
|
next = withRepositoryReplaced(config, updatedRepository(out, existing, { ...input, packages }));
|
|
594
599
|
saved = { verb: 'update', target: `${owner}/${name} in ${configPath}` };
|
|
595
600
|
}
|
|
596
|
-
|
|
601
|
+
const checked = validated(next);
|
|
602
|
+
out.planned(saved);
|
|
603
|
+
if (input.dry_run)
|
|
604
|
+
return 0;
|
|
605
|
+
saveConfig(checked, configPath);
|
|
597
606
|
out.done(saved);
|
|
598
607
|
return 0;
|
|
599
608
|
},
|
|
600
609
|
});
|
|
601
|
-
// aggregation_repo
|
|
602
|
-
const
|
|
603
|
-
|
|
604
|
-
|
|
610
|
+
// 設定のキーの管理。今のキーは aggregation_repo だけ
|
|
611
|
+
const CONFIG_KEY = z.enum(['aggregation_repo']).describe('Key of the project config (aggregation_repo: the Epic aggregation repository)');
|
|
612
|
+
function setAggregationRepository(out, value, options) {
|
|
613
|
+
if (!AGGREGATION_REPOSITORY_PATTERN.test(value))
|
|
614
|
+
stopWith(out, `give aggregation_repo as owner/repo: ${pythonStringRepr(value)}`, 'invalid-input');
|
|
615
|
+
const { config, configPath } = requireActiveWithPath(out);
|
|
616
|
+
const current = config.aggregation_repo;
|
|
617
|
+
if (current === value) {
|
|
618
|
+
const unchanged = { verb: 'unchanged', target: `aggregation_repo ${value}` };
|
|
619
|
+
out.planned(unchanged);
|
|
620
|
+
out.done(unchanged);
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
const operation = { verb: 'set', target: `aggregation_repo to ${value}` };
|
|
624
|
+
if (options.isDryRun) {
|
|
625
|
+
out.planned(current === undefined || current === '' ? operation : { ...operation, target: `${operation.target} (was ${current})` });
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
if (current !== undefined && current !== '') {
|
|
629
|
+
out.warning(options.isConfirmed ? `overwriting aggregation_repo: ${current} -> ${value}` : hinted `overwriting aggregation_repo: ${current} -> ${value}\npass ${inputHint(['project', 'set'], 'yes')} to omit this hint`);
|
|
630
|
+
}
|
|
631
|
+
saveConfig(withAggregationRepository(config, value), configPath);
|
|
632
|
+
out.done(operation);
|
|
633
|
+
}
|
|
634
|
+
function unsetAggregationRepository(out, isDryRun) {
|
|
635
|
+
const { config, configPath } = requireActiveWithPath(out);
|
|
636
|
+
const previous = config.aggregation_repo;
|
|
637
|
+
if (previous === undefined) {
|
|
638
|
+
const unchanged = { verb: 'unchanged', target: 'aggregation_repo (not set)' };
|
|
639
|
+
out.planned(unchanged);
|
|
640
|
+
out.done(unchanged);
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
const operation = { verb: 'remove', target: `aggregation_repo (was ${previous})` };
|
|
644
|
+
out.planned(operation);
|
|
645
|
+
if (isDryRun)
|
|
646
|
+
return;
|
|
647
|
+
saveConfig(withAggregationRepository(config, undefined), configPath);
|
|
648
|
+
out.done(operation);
|
|
649
|
+
}
|
|
650
|
+
// キーを足したら、ここに操作を足さないと型の確認で止まる
|
|
651
|
+
const CONFIG_KEY_OPERATIONS = {
|
|
652
|
+
aggregation_repo: {
|
|
653
|
+
get: (out) => {
|
|
654
|
+
out.data(requireActiveConfig(out).aggregation_repo ?? 'none');
|
|
655
|
+
},
|
|
656
|
+
set: setAggregationRepository,
|
|
657
|
+
unset: unsetAggregationRepository,
|
|
658
|
+
},
|
|
659
|
+
};
|
|
660
|
+
const projectSetCommand = defineCommand({
|
|
661
|
+
path: ['project', 'set'],
|
|
662
|
+
description: 'Set a key of the project config (aggregation_repo: the Epic aggregation repository)',
|
|
605
663
|
input: z.strictObject({
|
|
664
|
+
key: CONFIG_KEY,
|
|
606
665
|
value: z.string().describe('Aggregation repository (owner/repo form)'),
|
|
607
666
|
yes: z.boolean().default(false).describe('Overwrite an existing value without confirmation (a warning goes to stderr)'),
|
|
667
|
+
dry_run: dryRunInput,
|
|
608
668
|
}),
|
|
609
|
-
positional: ['value'],
|
|
610
|
-
shortFlags: { yes: '-y' },
|
|
669
|
+
positional: ['key', 'value'],
|
|
670
|
+
shortFlags: { yes: '-y', dry_run: '-n' },
|
|
611
671
|
interactive: false,
|
|
612
672
|
run: (input, io) => {
|
|
613
|
-
|
|
614
|
-
const { value, yes } = input;
|
|
615
|
-
if (!AGGREGATION_REPOSITORY_PATTERN.test(value))
|
|
616
|
-
stopWith(out, `give aggregation_repo as owner/repo: ${pythonStringRepr(value)}`);
|
|
617
|
-
const { config, configPath } = requireActiveWithPath(out);
|
|
618
|
-
const current = config.aggregation_repo;
|
|
619
|
-
if (current !== undefined && current !== '' && current !== value) {
|
|
620
|
-
out.warning(`overwriting aggregation_repo: ${current} -> ${value}${yes ? '' : '\npass --yes to omit this hint'}`);
|
|
621
|
-
}
|
|
622
|
-
else if (current === value) {
|
|
623
|
-
out.done({ verb: 'unchanged', target: `aggregation_repo ${value}` });
|
|
624
|
-
return Promise.resolve(0);
|
|
625
|
-
}
|
|
626
|
-
saveConfig(withAggregationRepository(config, value), configPath);
|
|
627
|
-
out.done({ verb: 'set', target: `aggregation_repo to ${value}` });
|
|
673
|
+
CONFIG_KEY_OPERATIONS[input.key].set(createOutput(input.dry_run, io), input.value, { isConfirmed: input.yes, isDryRun: input.dry_run });
|
|
628
674
|
return Promise.resolve(0);
|
|
629
675
|
},
|
|
630
676
|
});
|
|
631
|
-
const
|
|
632
|
-
path: ['project', 'unset
|
|
633
|
-
description: 'Clear the
|
|
634
|
-
input: z.strictObject({}),
|
|
635
|
-
positional: [],
|
|
677
|
+
const projectUnsetCommand = defineCommand({
|
|
678
|
+
path: ['project', 'unset'],
|
|
679
|
+
description: 'Clear a key of the project config; without aggregation_repo, creating an Epic needs --repo',
|
|
680
|
+
input: z.strictObject({ key: CONFIG_KEY, dry_run: dryRunInput }),
|
|
681
|
+
positional: ['key'],
|
|
682
|
+
shortFlags: { dry_run: '-n' },
|
|
636
683
|
interactive: false,
|
|
637
|
-
run: (
|
|
638
|
-
|
|
639
|
-
const { config, configPath } = requireActiveWithPath(out);
|
|
640
|
-
const previous = config.aggregation_repo;
|
|
641
|
-
if (previous === undefined) {
|
|
642
|
-
out.done({ verb: 'unchanged', target: 'aggregation_repo (not set)' });
|
|
643
|
-
return Promise.resolve(0);
|
|
644
|
-
}
|
|
645
|
-
saveConfig(withAggregationRepository(config, undefined), configPath);
|
|
646
|
-
out.done({ verb: 'remove', target: `aggregation_repo (was ${previous})` });
|
|
684
|
+
run: (input, io) => {
|
|
685
|
+
CONFIG_KEY_OPERATIONS[input.key].unset(createOutput(input.dry_run, io), input.dry_run);
|
|
647
686
|
return Promise.resolve(0);
|
|
648
687
|
},
|
|
649
688
|
});
|
|
650
|
-
const
|
|
651
|
-
path: ['project', '
|
|
652
|
-
description: 'Show the Epic aggregation repository
|
|
653
|
-
input: z.strictObject({}),
|
|
654
|
-
positional: [],
|
|
689
|
+
const projectGetCommand = defineCommand({
|
|
690
|
+
path: ['project', 'get'],
|
|
691
|
+
description: 'Show the value of a key of the project config (aggregation_repo: the Epic aggregation repository)',
|
|
692
|
+
input: z.strictObject({ key: CONFIG_KEY }),
|
|
693
|
+
positional: ['key'],
|
|
655
694
|
interactive: false,
|
|
656
|
-
run: (
|
|
657
|
-
|
|
658
|
-
out.data(requireActiveConfig(out).aggregation_repo ?? 'none');
|
|
695
|
+
run: (input, io) => {
|
|
696
|
+
CONFIG_KEY_OPERATIONS[input.key].get(createOutput(false, io));
|
|
659
697
|
return Promise.resolve(0);
|
|
660
698
|
},
|
|
661
699
|
});
|
|
662
700
|
/**
|
|
663
|
-
project
|
|
701
|
+
project のグループのコマンド。並びは help の一覧の順
|
|
664
702
|
*/
|
|
665
703
|
export const PROJECT_COMMANDS = [
|
|
666
704
|
listCommand,
|
|
667
705
|
searchCommand,
|
|
668
706
|
initCommand,
|
|
669
707
|
projectCreationCommand,
|
|
670
|
-
infoCommand,
|
|
671
708
|
activateCommand,
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
709
|
+
projectLinkCommand,
|
|
710
|
+
projectGetCommand,
|
|
711
|
+
projectSetCommand,
|
|
712
|
+
projectUnsetCommand,
|
|
676
713
|
];
|
|
677
714
|
//# sourceMappingURL=project.js.map
|