@pecot/workflow-mcp 0.0.0-stage → 5.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 +8 -0
- package/LICENSE +21 -0
- package/README.md +126 -2
- package/bin/pecot-workflow-mcp.mjs +10 -0
- package/cli/dist/cli.d.ts +26 -0
- package/cli/dist/cli.js +222 -0
- package/cli/dist/commands/cell-table.d.ts +3 -0
- package/cli/dist/commands/cell-table.js +495 -0
- package/cli/dist/commands/command-binding.d.ts +26 -0
- package/cli/dist/commands/command-binding.js +266 -0
- package/cli/dist/commands/command-definition.d.ts +136 -0
- package/cli/dist/commands/command-definition.js +101 -0
- package/cli/dist/commands/command-help.d.ts +8 -0
- package/cli/dist/commands/command-help.js +173 -0
- package/cli/dist/commands/command-stop.d.ts +19 -0
- package/cli/dist/commands/command-stop.js +30 -0
- package/cli/dist/commands/dependabot.d.ts +3 -0
- package/cli/dist/commands/dependabot.js +165 -0
- package/cli/dist/commands/directory-option.d.ts +7 -0
- package/cli/dist/commands/directory-option.js +48 -0
- package/cli/dist/commands/failure.d.ts +13 -0
- package/cli/dist/commands/failure.js +33 -0
- package/cli/dist/commands/fuzzy.d.ts +7 -0
- package/cli/dist/commands/fuzzy.js +79 -0
- package/cli/dist/commands/github-client.d.ts +12 -0
- package/cli/dist/commands/github-client.js +23 -0
- package/cli/dist/commands/global-options.d.ts +25 -0
- package/cli/dist/commands/global-options.js +83 -0
- package/cli/dist/commands/help-layout.d.ts +40 -0
- package/cli/dist/commands/help-layout.js +117 -0
- package/cli/dist/commands/help.d.ts +8 -0
- package/cli/dist/commands/help.js +55 -0
- package/cli/dist/commands/input-schema.d.ts +14 -0
- package/cli/dist/commands/input-schema.js +56 -0
- package/cli/dist/commands/issue-board.d.ts +38 -0
- package/cli/dist/commands/issue-board.js +62 -0
- package/cli/dist/commands/issue-comment.d.ts +3 -0
- package/cli/dist/commands/issue-comment.js +196 -0
- package/cli/dist/commands/issue-create.d.ts +3 -0
- package/cli/dist/commands/issue-create.js +329 -0
- package/cli/dist/commands/issue-project.d.ts +3 -0
- package/cli/dist/commands/issue-project.js +176 -0
- package/cli/dist/commands/issue-quick.d.ts +3 -0
- package/cli/dist/commands/issue-quick.js +126 -0
- package/cli/dist/commands/issue-read.d.ts +3 -0
- package/cli/dist/commands/issue-read.js +80 -0
- package/cli/dist/commands/issue-shared.d.ts +159 -0
- package/cli/dist/commands/issue-shared.js +419 -0
- package/cli/dist/commands/issue.d.ts +4 -0
- package/cli/dist/commands/issue.js +15 -0
- package/cli/dist/commands/names.d.ts +9 -0
- package/cli/dist/commands/names.js +16 -0
- package/cli/dist/commands/output.d.ts +78 -0
- package/cli/dist/commands/output.js +187 -0
- package/cli/dist/commands/pr.d.ts +3 -0
- package/cli/dist/commands/pr.js +933 -0
- package/cli/dist/commands/project-info.d.ts +48 -0
- package/cli/dist/commands/project-info.js +181 -0
- package/cli/dist/commands/project-sync.d.ts +91 -0
- package/cli/dist/commands/project-sync.js +273 -0
- package/cli/dist/commands/project.d.ts +5 -0
- package/cli/dist/commands/project.js +677 -0
- package/cli/dist/commands/registry.d.ts +6 -0
- package/cli/dist/commands/registry.js +27 -0
- package/cli/dist/commands/release.d.ts +10 -0
- package/cli/dist/commands/release.js +414 -0
- package/cli/dist/commands/repository-display.d.ts +3 -0
- package/cli/dist/commands/repository-display.js +7 -0
- package/cli/dist/commands/repository-match.d.ts +14 -0
- package/cli/dist/commands/repository-match.js +33 -0
- package/cli/dist/commands/repository.d.ts +5 -0
- package/cli/dist/commands/repository.js +265 -0
- package/cli/dist/commands/rich-panel.d.ts +22 -0
- package/cli/dist/commands/rich-panel.js +295 -0
- package/cli/dist/commands/security.d.ts +3 -0
- package/cli/dist/commands/security.js +164 -0
- package/cli/dist/commands/session.d.ts +3 -0
- package/cli/dist/commands/session.js +161 -0
- package/cli/dist/commands/tracker-sync.d.ts +58 -0
- package/cli/dist/commands/tracker-sync.js +53 -0
- package/cli/dist/commands/usage-error.d.ts +47 -0
- package/cli/dist/commands/usage-error.js +72 -0
- package/cli/dist/commands/value-types.d.ts +46 -0
- package/cli/dist/commands/value-types.js +94 -0
- package/cli/dist/commands/work-target.d.ts +13 -0
- package/cli/dist/commands/work-target.js +41 -0
- package/cli/dist/commands/worktree.d.ts +3 -0
- package/cli/dist/commands/worktree.js +335 -0
- package/cli/dist/domain/api-error-detail.d.ts +10 -0
- package/cli/dist/domain/api-error-detail.js +25 -0
- package/cli/dist/domain/branch-name.d.ts +5 -0
- package/cli/dist/domain/branch-name.js +10 -0
- package/cli/dist/domain/changelog.d.ts +43 -0
- package/cli/dist/domain/changelog.js +107 -0
- package/cli/dist/domain/config.d.ts +215 -0
- package/cli/dist/domain/config.js +300 -0
- package/cli/dist/domain/dependabot-pull-requests.d.ts +82 -0
- package/cli/dist/domain/dependabot-pull-requests.js +338 -0
- package/cli/dist/domain/dependabot-source.d.ts +51 -0
- package/cli/dist/domain/dependabot-source.js +4 -0
- package/cli/dist/domain/dependabot.d.ts +47 -0
- package/cli/dist/domain/dependabot.js +88 -0
- package/cli/dist/domain/errors.d.ts +19 -0
- package/cli/dist/domain/errors.js +31 -0
- package/cli/dist/domain/field-options.d.ts +31 -0
- package/cli/dist/domain/field-options.js +44 -0
- package/cli/dist/domain/format.d.ts +47 -0
- package/cli/dist/domain/format.js +168 -0
- package/cli/dist/domain/frontmatter.d.ts +122 -0
- package/cli/dist/domain/frontmatter.js +264 -0
- package/cli/dist/domain/git-runner.d.ts +10 -0
- package/cli/dist/domain/git-runner.js +4 -0
- package/cli/dist/domain/git-url.d.ts +17 -0
- package/cli/dist/domain/git-url.js +30 -0
- package/cli/dist/domain/issue-kind.d.ts +16 -0
- package/cli/dist/domain/issue-kind.js +16 -0
- package/cli/dist/domain/issue-readout.d.ts +107 -0
- package/cli/dist/domain/issue-readout.js +4 -0
- package/cli/dist/domain/json-null.d.ts +2 -0
- package/cli/dist/domain/json-null.js +5 -0
- package/cli/dist/domain/json.d.ts +21 -0
- package/cli/dist/domain/json.js +47 -0
- package/cli/dist/domain/prerequisites.d.ts +32 -0
- package/cli/dist/domain/prerequisites.js +192 -0
- package/cli/dist/domain/pull-request.d.ts +134 -0
- package/cli/dist/domain/pull-request.js +232 -0
- package/cli/dist/domain/python-format.d.ts +105 -0
- package/cli/dist/domain/python-format.js +304 -0
- package/cli/dist/domain/readiness.d.ts +172 -0
- package/cli/dist/domain/readiness.js +280 -0
- package/cli/dist/domain/reference-parser.d.ts +49 -0
- package/cli/dist/domain/reference-parser.js +119 -0
- package/cli/dist/domain/release.d.ts +49 -0
- package/cli/dist/domain/release.js +72 -0
- package/cli/dist/domain/repository-policy.d.ts +32 -0
- package/cli/dist/domain/repository-policy.js +65 -0
- package/cli/dist/domain/repository-resolver.d.ts +57 -0
- package/cli/dist/domain/repository-resolver.js +119 -0
- package/cli/dist/domain/sections.d.ts +69 -0
- package/cli/dist/domain/sections.js +514 -0
- package/cli/dist/domain/security-alerts-source.d.ts +29 -0
- package/cli/dist/domain/security-alerts-source.js +4 -0
- package/cli/dist/domain/security-alerts.d.ts +52 -0
- package/cli/dist/domain/security-alerts.js +107 -0
- package/cli/dist/domain/security-tracker.d.ts +115 -0
- package/cli/dist/domain/security-tracker.js +353 -0
- package/cli/dist/domain/state.d.ts +29 -0
- package/cli/dist/domain/state.js +56 -0
- package/cli/dist/domain/tracker-body.d.ts +70 -0
- package/cli/dist/domain/tracker-body.js +65 -0
- package/cli/dist/domain/yaml-document.d.ts +5 -0
- package/cli/dist/domain/yaml-document.js +206 -0
- package/cli/dist/infra/authored-notes.d.ts +37 -0
- package/cli/dist/infra/authored-notes.js +66 -0
- package/cli/dist/infra/changelog-file.d.ts +19 -0
- package/cli/dist/infra/changelog-file.js +43 -0
- package/cli/dist/infra/child-stdin.d.ts +4 -0
- package/cli/dist/infra/child-stdin.js +8 -0
- package/cli/dist/infra/config-store.d.ts +49 -0
- package/cli/dist/infra/config-store.js +121 -0
- package/cli/dist/infra/diagnostics.d.ts +9 -0
- package/cli/dist/infra/diagnostics.js +2 -0
- package/cli/dist/infra/file-kind.d.ts +9 -0
- package/cli/dist/infra/file-kind.js +26 -0
- package/cli/dist/infra/frontmatter-file.d.ts +14 -0
- package/cli/dist/infra/frontmatter-file.js +30 -0
- package/cli/dist/infra/git.d.ts +74 -0
- package/cli/dist/infra/git.js +133 -0
- package/cli/dist/infra/github/auth.d.ts +60 -0
- package/cli/dist/infra/github/auth.js +158 -0
- package/cli/dist/infra/github/client.d.ts +173 -0
- package/cli/dist/infra/github/client.js +576 -0
- package/cli/dist/infra/github/dependabot-source.d.ts +13 -0
- package/cli/dist/infra/github/dependabot-source.js +33 -0
- package/cli/dist/infra/github/errors.d.ts +47 -0
- package/cli/dist/infra/github/errors.js +42 -0
- package/cli/dist/infra/github/index.d.ts +13 -0
- package/cli/dist/infra/github/index.js +19 -0
- package/cli/dist/infra/github/issues.d.ts +129 -0
- package/cli/dist/infra/github/issues.js +273 -0
- package/cli/dist/infra/github/payload.d.ts +44 -0
- package/cli/dist/infra/github/payload.js +80 -0
- package/cli/dist/infra/github/projects.d.ts +108 -0
- package/cli/dist/infra/github/projects.js +303 -0
- package/cli/dist/infra/github/pulls.d.ts +80 -0
- package/cli/dist/infra/github/pulls.js +161 -0
- package/cli/dist/infra/github/queries.d.ts +36 -0
- package/cli/dist/infra/github/queries.js +883 -0
- package/cli/dist/infra/github/readout.d.ts +18 -0
- package/cli/dist/infra/github/readout.js +156 -0
- package/cli/dist/infra/github/repos.d.ts +68 -0
- package/cli/dist/infra/github/repos.js +137 -0
- package/cli/dist/infra/github/rest-path.d.ts +14 -0
- package/cli/dist/infra/github/rest-path.js +31 -0
- package/cli/dist/infra/github/security-alerts-source.d.ts +15 -0
- package/cli/dist/infra/github/security-alerts-source.js +73 -0
- package/cli/dist/infra/gitignore-spec.d.ts +36 -0
- package/cli/dist/infra/gitignore-spec.js +235 -0
- package/cli/dist/infra/nx-scope.d.ts +51 -0
- package/cli/dist/infra/nx-scope.js +182 -0
- package/cli/dist/infra/os-error.d.ts +24 -0
- package/cli/dist/infra/os-error.js +38 -0
- package/cli/dist/infra/paths.d.ts +88 -0
- package/cli/dist/infra/paths.js +234 -0
- package/cli/dist/infra/state-store.d.ts +45 -0
- package/cli/dist/infra/state-store.js +118 -0
- package/cli/dist/infra/template-store.d.ts +15 -0
- package/cli/dist/infra/template-store.js +34 -0
- package/cli/dist/infra/text-file.d.ts +12 -0
- package/cli/dist/infra/text-file.js +33 -0
- package/cli/dist/infra/worktree-copy.d.ts +24 -0
- package/cli/dist/infra/worktree-copy.js +95 -0
- package/cli/dist/infra/worktree-links.d.ts +139 -0
- package/cli/dist/infra/worktree-links.js +433 -0
- package/cli/dist/infra/worktree-setup.d.ts +21 -0
- package/cli/dist/infra/worktree-setup.js +41 -0
- package/cli/dist/infra/worktree.d.ts +174 -0
- package/cli/dist/infra/worktree.js +567 -0
- package/cli/dist/mcp/result.d.ts +33 -0
- package/cli/dist/mcp/result.js +52 -0
- package/cli/dist/mcp/serve.d.ts +51 -0
- package/cli/dist/mcp/serve.js +183 -0
- package/cli/dist/mcp/server.d.ts +21 -0
- package/cli/dist/mcp/server.js +128 -0
- package/cli/dist/mcp/session-directory.d.ts +26 -0
- package/cli/dist/mcp/session-directory.js +84 -0
- package/cli/dist/package.json +1 -0
- package/cli/dist/version.d.ts +17 -0
- package/cli/dist/version.js +42 -0
- package/cli/templates/comment/merge-diff.md +34 -0
- package/cli/templates/comment/plan.md +181 -0
- package/cli/templates/comment/precede-notify.md +33 -0
- package/cli/templates/comment/review-findings.md +42 -0
- package/cli/templates/comment/review-resolution.md +48 -0
- package/cli/templates/issue/bug.md +63 -0
- package/cli/templates/issue/epic.md +54 -0
- package/cli/templates/issue/task-implement.md +67 -0
- package/cli/templates/issue/task.md +48 -0
- package/cli/templates/issue/tracker.md +48 -0
- package/cli/templates/pr/create.md +123 -0
- package/cli/templates/pr/release.md +56 -0
- package/hooks/lib/core/pecot-gitignore-ensure.sh +48 -0
- package/npm-shrinkwrap.json +83 -0
- package/package.json +22 -4
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CommandDefinition } from './command-definition.js';
|
|
2
|
+
export { defineCommand, toolNameOf } from './command-definition.js';
|
|
3
|
+
export type { CommandDefinition, CommandIo, PreparedCommand } from './command-definition.js';
|
|
4
|
+
export declare const COMMANDS: readonly CommandDefinition[];
|
|
5
|
+
export declare function findCommand(path: readonly string[], commands?: readonly CommandDefinition[]): CommandDefinition | undefined;
|
|
6
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DEPENDABOT_COMMANDS } from './dependabot.js';
|
|
2
|
+
import { ISSUE_BOARD_COMMANDS, ISSUE_COMMANDS } from './issue.js';
|
|
3
|
+
import { PR_COMMANDS } from './pr.js';
|
|
4
|
+
import { PROJECT_COMMANDS } from './project.js';
|
|
5
|
+
import { RELEASE_COMMANDS } from './release.js';
|
|
6
|
+
import { REPOSITORY_COMMANDS } from './repository.js';
|
|
7
|
+
import { SECURITY_COMMANDS } from './security.js';
|
|
8
|
+
import { SESSION_COMMANDS } from './session.js';
|
|
9
|
+
import { WORKTREE_COMMANDS } from './worktree.js';
|
|
10
|
+
export { defineCommand, toolNameOf } from './command-definition.js';
|
|
11
|
+
// 並びは Python の登録順。help の一覧と「近いコマンド」の案内が、この順で出る
|
|
12
|
+
export const COMMANDS = [
|
|
13
|
+
...ISSUE_BOARD_COMMANDS,
|
|
14
|
+
...REPOSITORY_COMMANDS,
|
|
15
|
+
...PROJECT_COMMANDS,
|
|
16
|
+
...ISSUE_COMMANDS,
|
|
17
|
+
...PR_COMMANDS,
|
|
18
|
+
...SESSION_COMMANDS,
|
|
19
|
+
...RELEASE_COMMANDS,
|
|
20
|
+
...SECURITY_COMMANDS,
|
|
21
|
+
...DEPENDABOT_COMMANDS,
|
|
22
|
+
...WORKTREE_COMMANDS,
|
|
23
|
+
];
|
|
24
|
+
export function findCommand(path, commands = COMMANDS) {
|
|
25
|
+
return commands.find(command => command.path.join(' ') === path.join(' '));
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RepositoryReference } from '../domain/repository-resolver.js';
|
|
2
|
+
import type { Output } from './output.js';
|
|
3
|
+
import type { CommandDefinition } from './command-definition.js';
|
|
4
|
+
/**
|
|
5
|
+
順は採用済みの --repo、グローバルの --repo、主の remote。決められないと error の行を出して undefined を返す。
|
|
6
|
+
remote は process.cwd() から読む
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveReleaseTargetRepository(adopted: RepositoryReference | undefined, explicit: string | undefined, out: Readonly<Output>): RepositoryReference | undefined;
|
|
9
|
+
export declare const RELEASE_COMMANDS: readonly CommandDefinition[];
|
|
10
|
+
//# sourceMappingURL=release.d.ts.map
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
// release preflight・create・merge。移す元は cli/commands/release.py。
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { describeApiError } from '../domain/api-error-detail.js';
|
|
5
|
+
import { ChangelogFileNotFoundError, InvalidVersionError, validateSemver } from '../domain/changelog.js';
|
|
6
|
+
import { effectiveReleaseType, findPackage, findRepository, getDevelopBranch, getReleaseBranch } from '../domain/config.js';
|
|
7
|
+
import { DependabotAlertError, fetchDependabotAlertStatus } from '../domain/dependabot.js';
|
|
8
|
+
import { PecotError } from '../domain/errors.js';
|
|
9
|
+
import { pythonStringRepr } from '../domain/python-format.js';
|
|
10
|
+
import { parsePullRequestReference, ReferenceParseError } from '../domain/reference-parser.js';
|
|
11
|
+
import { ReleaseError, runPreflight } from '../domain/release.js';
|
|
12
|
+
import { splitOwnerRepository } from '../domain/repository-resolver.js';
|
|
13
|
+
import { fetchCodeScanningStatus, fetchSecretScanningStatus, SecurityAlertError } from '../domain/security-alerts.js';
|
|
14
|
+
import { extractReleaseNotesFromFile, readChangelogIfExists, resolveChangelogPath } from '../infra/changelog-file.js';
|
|
15
|
+
import { loadActiveConfig } from '../infra/config-store.js';
|
|
16
|
+
import { gitRunnerFor, gitToplevel, primaryRemoteName, primaryRemoteRepository } from '../infra/git.js';
|
|
17
|
+
import { TransportFailure } from '../infra/github/client.js';
|
|
18
|
+
import { createDependabotSource } from '../infra/github/dependabot-source.js';
|
|
19
|
+
import { GitHubAPIError, GitHubNotFoundError } from '../infra/github/errors.js';
|
|
20
|
+
import { createScanAlertSource } from '../infra/github/security-alerts-source.js';
|
|
21
|
+
import { NO_ACTIVE_PROJECT } from './command-stop.js';
|
|
22
|
+
import { createGitHubClient, makeClient } from './github-client.js';
|
|
23
|
+
import { createOutput } from './output.js';
|
|
24
|
+
import { defineCommand } from './command-definition.js';
|
|
25
|
+
import { requireRepositoryMatch } from './repository-match.js';
|
|
26
|
+
import { USAGE_EXIT_CODE } from './usage-error.js';
|
|
27
|
+
const FAILURE = 1;
|
|
28
|
+
/**
|
|
29
|
+
順は採用済みの --repo、グローバルの --repo、主の remote。決められないと error の行を出して undefined を返す。
|
|
30
|
+
remote は process.cwd() から読む
|
|
31
|
+
*/
|
|
32
|
+
export function resolveReleaseTargetRepository(adopted, explicit, out) {
|
|
33
|
+
if (adopted !== undefined)
|
|
34
|
+
return adopted;
|
|
35
|
+
if (explicit !== undefined) {
|
|
36
|
+
const parts = splitOwnerRepository(explicit);
|
|
37
|
+
if (parts === undefined) {
|
|
38
|
+
out.error(`invalid --repo format: ${pythonStringRepr(explicit)}\nspecify it as owner/repo`);
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return parts;
|
|
42
|
+
}
|
|
43
|
+
const remote = primaryRemoteRepository(process.cwd());
|
|
44
|
+
if (remote === undefined) {
|
|
45
|
+
out.error('could not read the repository from the git remote');
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
return { owner: remote.owner, repository: remote.repository };
|
|
49
|
+
}
|
|
50
|
+
// 4 つの場合(packages の有無と --package の有無)を分ける。矛盾があれば error の行を出して undefined を返す
|
|
51
|
+
function resolvePackageContext(out, repositoryConfig, packageName, gitRoot, owner, repository) {
|
|
52
|
+
const packages = repositoryConfig?.packages ?? [];
|
|
53
|
+
if (repositoryConfig !== undefined && packages.length > 0) {
|
|
54
|
+
const names = packages.map(item => item.name).join(', ');
|
|
55
|
+
if (packageName === undefined) {
|
|
56
|
+
out.error(`${owner}/${repository} is a monorepo\nspecify --package (available: ${names})`);
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
const found = findPackage(repositoryConfig, packageName);
|
|
60
|
+
if (found === undefined) {
|
|
61
|
+
out.error(`package '${packageName}' is not registered in ${owner}/${repository}\navailable: ${names}`);
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
return { changelogPath: path.isAbsolute(found.changelog) ? found.changelog : path.join(gitRoot, found.changelog), tagPrefix: found.name };
|
|
65
|
+
}
|
|
66
|
+
if (packageName !== undefined) {
|
|
67
|
+
out.error(`${owner}/${repository} has no packages configured\n--package can only be used in a monorepo`);
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return { changelogPath: resolveChangelogPath(gitRoot, repositoryConfig?.changelog_file), tagPrefix: undefined };
|
|
71
|
+
}
|
|
72
|
+
function requireBranchSetting(out, branch, kind, owner, repository) {
|
|
73
|
+
if (branch === undefined || branch === '') {
|
|
74
|
+
out.error(`${kind}_branch is not set for ${owner}/${repository}\nset it with: pecot project set-repo ${owner}/${repository} --${kind}-branch <branch>`);
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
return branch;
|
|
78
|
+
}
|
|
79
|
+
function loadReleaseContext(out, adopted, explicit, packageName, options = {}) {
|
|
80
|
+
const cwd = process.cwd();
|
|
81
|
+
const gitRoot = gitToplevel({ cwd });
|
|
82
|
+
if (gitRoot === undefined) {
|
|
83
|
+
out.error('could not find the root directory of the git repository');
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
const target = resolveReleaseTargetRepository(adopted, explicit, out);
|
|
87
|
+
if (target === undefined)
|
|
88
|
+
return undefined;
|
|
89
|
+
const { owner, repository } = target;
|
|
90
|
+
const config = loadActiveConfig();
|
|
91
|
+
if (config === undefined) {
|
|
92
|
+
out.error(NO_ACTIVE_PROJECT);
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
const repositoryConfig = findRepository(config, owner, repository);
|
|
96
|
+
if (repositoryConfig !== undefined && options.nxAlertsOnly === true && effectiveReleaseType(repositoryConfig) === 'nx') {
|
|
97
|
+
if (packageName !== undefined || options.version !== undefined) {
|
|
98
|
+
out.error('the version argument and --package cannot be used when release_type is nx\nrun it without arguments (Nx Release decides the version)');
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
return { config, owner, repository, repositoryConfig, changelogPath: resolveChangelogPath(gitRoot, repositoryConfig.changelog_file), tagPrefix: undefined };
|
|
102
|
+
}
|
|
103
|
+
const resolved = resolvePackageContext(out, repositoryConfig, packageName, gitRoot, owner, repository);
|
|
104
|
+
return resolved === undefined ? undefined : { config, owner, repository, repositoryConfig, ...resolved };
|
|
105
|
+
}
|
|
106
|
+
function alertLabel(number, packageName, severity) {
|
|
107
|
+
const detail = [packageName, severity].filter(value => value !== undefined && value !== '').join(', ');
|
|
108
|
+
return detail === '' ? `#${String(number)}` : `#${String(number)} (${detail})`;
|
|
109
|
+
}
|
|
110
|
+
// 理由は 1 行目だけを使い、末尾の句点を落とす
|
|
111
|
+
function warnAlertsUnavailable(out, reason) {
|
|
112
|
+
const [first = ''] = reason.trim().split(/\r\n|[\n\r]/u, 1);
|
|
113
|
+
out.warning(`could not check Dependabot alerts. The release is not blocked.\nreason: ${first.trim().replace(/\.+$/u, '').trimEnd()}`);
|
|
114
|
+
}
|
|
115
|
+
// open の Dependabot alert は警告だけで、リリースを止めない
|
|
116
|
+
async function checkDependabotAlerts(out, config, owner, repository) {
|
|
117
|
+
let status;
|
|
118
|
+
try {
|
|
119
|
+
const client = createGitHubClient(out, config.host);
|
|
120
|
+
status = await fetchDependabotAlertStatus(createDependabotSource(client), config.host, owner, repository);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
if (error instanceof DependabotAlertError) {
|
|
124
|
+
warnAlertsUnavailable(out, error.message);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (error instanceof GitHubAPIError) {
|
|
128
|
+
warnAlertsUnavailable(out, error.message);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
if (!status.enabled) {
|
|
134
|
+
out.done({ verb: 'skip', target: 'Dependabot alerts (feature disabled)' });
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (status.openCount === 0) {
|
|
138
|
+
out.count('open Dependabot alerts', 0);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const severity = status.maxSeverity === undefined ? '' : ` (highest severity: ${status.maxSeverity})`;
|
|
142
|
+
const listing = status.openAlerts.map(alert => `\n${alertLabel(alert.number, alert.package, alert.severity)}`).join('');
|
|
143
|
+
const noun = status.openCount === 1 ? 'alert' : 'alerts';
|
|
144
|
+
out.warning(`${String(status.openCount)} open Dependabot ${noun}${severity}. The release is not blocked.${listing}\n→ ${status.alertsUrl}`);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
code scanning・secret scanning の open の alert があれば、false を返す。機能が無効のリポジトリは通る
|
|
148
|
+
*/
|
|
149
|
+
async function isScanningPassed(out, name, fetchStatus) {
|
|
150
|
+
let status;
|
|
151
|
+
try {
|
|
152
|
+
status = await fetchStatus();
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
if (!(error instanceof SecurityAlertError))
|
|
156
|
+
throw error;
|
|
157
|
+
out.error(`could not check ${name}: ${error.message}`);
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
if (!status.enabled) {
|
|
161
|
+
out.done({ verb: 'skip', target: `${name} (feature disabled)` });
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
if (status.openCount === 0) {
|
|
165
|
+
out.count(`open ${name} alerts`, 0);
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
const listing = status.openNumbers.map(number => `\n#${String(number)}`).join('');
|
|
169
|
+
out.error(`${name} has ${String(status.openCount)} open ${status.openCount === 1 ? 'alert' : 'alerts'}${listing}\n→ ${status.alertsUrl}\nclose them (fixed, or dismissed with a reason) and run again`);
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
3 種を確かめる。1 つが失敗しても残りを続け、最後に成否を返す
|
|
174
|
+
*/
|
|
175
|
+
async function areAlertsPassed(out, config, owner, repository) {
|
|
176
|
+
const checks = [
|
|
177
|
+
async () => {
|
|
178
|
+
await checkDependabotAlerts(out, config, owner, repository);
|
|
179
|
+
return true;
|
|
180
|
+
},
|
|
181
|
+
async () => await isScanningPassed(out, 'code scanning', async () => await fetchCodeScanningStatus(createScanAlertSource(createGitHubClient(out, config.host)), config.host, owner, repository)),
|
|
182
|
+
async () => await isScanningPassed(out, 'secret scanning', async () => await fetchSecretScanningStatus(createScanAlertSource(createGitHubClient(out, config.host)), config.host, owner, repository)),
|
|
183
|
+
];
|
|
184
|
+
let isPassed = true;
|
|
185
|
+
for (const check of checks) {
|
|
186
|
+
try {
|
|
187
|
+
if (!await check())
|
|
188
|
+
isPassed = false;
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
if (!(error instanceof PecotError) && !(error instanceof TransportFailure))
|
|
192
|
+
throw error;
|
|
193
|
+
out.error(`could not check alerts: ${error.message}`);
|
|
194
|
+
isPassed = false;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return isPassed;
|
|
198
|
+
}
|
|
199
|
+
const preflight = defineCommand({
|
|
200
|
+
path: ['release', 'preflight'],
|
|
201
|
+
description: 'Run the pre-release checks (preflight); for an nx repository only the alerts are checked',
|
|
202
|
+
input: z.object({
|
|
203
|
+
version: z.string().optional().describe('Release version (detected from the CHANGELOG when omitted)'),
|
|
204
|
+
package: z.string().optional().describe('Package name in a monorepo (required for repositories with packages configured)'),
|
|
205
|
+
}),
|
|
206
|
+
positional: ['version'],
|
|
207
|
+
interactive: false,
|
|
208
|
+
run: async (input, io) => {
|
|
209
|
+
const adopted = requireRepositoryMatch('warn', input.repo, io, process.cwd());
|
|
210
|
+
const out = createOutput(false, io);
|
|
211
|
+
const cwd = process.cwd();
|
|
212
|
+
const context = loadReleaseContext(out, adopted, input.repo, input.package, { version: input.version, nxAlertsOnly: true });
|
|
213
|
+
if (context === undefined)
|
|
214
|
+
return FAILURE;
|
|
215
|
+
const { config, owner, repository } = context;
|
|
216
|
+
const isAlertsPassed = await areAlertsPassed(out, config, owner, repository);
|
|
217
|
+
if (!isAlertsPassed)
|
|
218
|
+
return FAILURE;
|
|
219
|
+
if (context.repositoryConfig !== undefined && effectiveReleaseType(context.repositoryConfig) === 'nx')
|
|
220
|
+
return 0;
|
|
221
|
+
const developBranch = requireBranchSetting(out, getDevelopBranch(config, owner, repository), 'develop', owner, repository);
|
|
222
|
+
if (developBranch === undefined)
|
|
223
|
+
return FAILURE;
|
|
224
|
+
const releaseBranch = requireBranchSetting(out, getReleaseBranch(config, owner, repository), 'release', owner, repository);
|
|
225
|
+
if (releaseBranch === undefined)
|
|
226
|
+
return FAILURE;
|
|
227
|
+
const remote = primaryRemoteName(cwd) ?? 'origin';
|
|
228
|
+
try {
|
|
229
|
+
const result = runPreflight({
|
|
230
|
+
changelogPath: context.changelogPath,
|
|
231
|
+
changelogContent: readChangelogIfExists(context.changelogPath),
|
|
232
|
+
developBranch,
|
|
233
|
+
releaseBranch,
|
|
234
|
+
version: input.version,
|
|
235
|
+
tagPrefix: context.tagPrefix,
|
|
236
|
+
remote,
|
|
237
|
+
}, gitRunnerFor(cwd));
|
|
238
|
+
out.count(`commits to release (${remote}/${result.developBranch} -> ${remote}/${result.releaseBranch})`, result.diffCount);
|
|
239
|
+
out.data(`version: ${result.version}\ntag: ${result.tagName}\n\n${result.releaseNotes}`);
|
|
240
|
+
return 0;
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
if (!(error instanceof ReleaseError))
|
|
244
|
+
throw error;
|
|
245
|
+
out.error(error.message);
|
|
246
|
+
return FAILURE;
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
const create = defineCommand({
|
|
251
|
+
path: ['release', 'create'],
|
|
252
|
+
description: 'Create a GitHub release and its tag (the release notes come from the CHANGELOG)',
|
|
253
|
+
input: z.object({
|
|
254
|
+
version: z.string().describe('Release version (for example 0.6.1)'),
|
|
255
|
+
dry_run: z.boolean().default(false).describe('Show what would happen without changing anything'),
|
|
256
|
+
package: z.string().optional().describe('Package name in a monorepo (required for repositories with packages configured)'),
|
|
257
|
+
}),
|
|
258
|
+
positional: ['version'],
|
|
259
|
+
interactive: false,
|
|
260
|
+
run: async (input, io) => {
|
|
261
|
+
const adopted = requireRepositoryMatch('warn', input.repo, io, process.cwd());
|
|
262
|
+
const out = createOutput(input.dry_run, io);
|
|
263
|
+
try {
|
|
264
|
+
validateSemver(input.version);
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
if (!(error instanceof InvalidVersionError))
|
|
268
|
+
throw error;
|
|
269
|
+
out.error(error.message);
|
|
270
|
+
return FAILURE;
|
|
271
|
+
}
|
|
272
|
+
const context = loadReleaseContext(out, adopted, input.repo, input.package);
|
|
273
|
+
if (context === undefined)
|
|
274
|
+
return FAILURE;
|
|
275
|
+
const { config, owner, repository, tagPrefix } = context;
|
|
276
|
+
let releaseNotes;
|
|
277
|
+
try {
|
|
278
|
+
releaseNotes = extractReleaseNotesFromFile(context.changelogPath, input.version);
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
if (!(error instanceof PecotError) && !(error instanceof ChangelogFileNotFoundError))
|
|
282
|
+
throw error;
|
|
283
|
+
out.error(error.message);
|
|
284
|
+
return FAILURE;
|
|
285
|
+
}
|
|
286
|
+
const releaseBranch = requireBranchSetting(out, getReleaseBranch(config, owner, repository), 'release', owner, repository);
|
|
287
|
+
if (releaseBranch === undefined)
|
|
288
|
+
return FAILURE;
|
|
289
|
+
const tagName = tagPrefix === undefined ? `v${input.version}` : `${tagPrefix}-v${input.version}`;
|
|
290
|
+
const releaseName = tagPrefix === undefined ? tagName : `${tagPrefix} v${input.version}`;
|
|
291
|
+
const operation = { verb: 'create', target: `release ${tagName} on ${releaseBranch}` };
|
|
292
|
+
if (input.dry_run) {
|
|
293
|
+
out.planned(operation);
|
|
294
|
+
out.data(releaseNotes);
|
|
295
|
+
return 0;
|
|
296
|
+
}
|
|
297
|
+
const client = makeClient(out, config);
|
|
298
|
+
if (client === undefined)
|
|
299
|
+
return FAILURE;
|
|
300
|
+
try {
|
|
301
|
+
const result = await client.createRelease(owner, repository, tagName, releaseName, releaseNotes, { targetCommitish: releaseBranch });
|
|
302
|
+
out.done(operation);
|
|
303
|
+
const url = result['html_url'];
|
|
304
|
+
out.data(typeof url === 'string' ? url : '');
|
|
305
|
+
return 0;
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
if (!(error instanceof GitHubAPIError))
|
|
309
|
+
throw error;
|
|
310
|
+
out.error(`could not create release ${tagName} in ${owner}/${repository}: ${describeApiError(error)}`);
|
|
311
|
+
return FAILURE;
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
const merge = defineCommand({
|
|
316
|
+
path: ['release', 'merge'],
|
|
317
|
+
description: 'Merge a release PR with a regular merge',
|
|
318
|
+
input: z.object({
|
|
319
|
+
pr_ref: z.string().describe('PR reference (owner/repo/123)'),
|
|
320
|
+
dry_run: z.boolean().default(false).describe('Show what would happen without merging'),
|
|
321
|
+
delete_branch: z.boolean().default(false).describe('Delete the branch after merging'),
|
|
322
|
+
admin: z.boolean().default(false).describe('Merge with admin rights (skip the mergeability check)'),
|
|
323
|
+
}),
|
|
324
|
+
positional: ['pr_ref'],
|
|
325
|
+
shortFlags: { dry_run: '-n', delete_branch: '-d' },
|
|
326
|
+
interactive: false,
|
|
327
|
+
run: async (input, io) => {
|
|
328
|
+
requireRepositoryMatch('reject', input.repo, io, process.cwd());
|
|
329
|
+
const out = createOutput(input.dry_run, io);
|
|
330
|
+
const config = loadActiveConfig();
|
|
331
|
+
if (config === undefined) {
|
|
332
|
+
out.error(NO_ACTIVE_PROJECT);
|
|
333
|
+
return FAILURE;
|
|
334
|
+
}
|
|
335
|
+
let reference;
|
|
336
|
+
try {
|
|
337
|
+
reference = parsePullRequestReference(input.pr_ref);
|
|
338
|
+
}
|
|
339
|
+
catch (error) {
|
|
340
|
+
if (!(error instanceof ReferenceParseError))
|
|
341
|
+
throw error;
|
|
342
|
+
out.error(error.message);
|
|
343
|
+
return USAGE_EXIT_CODE;
|
|
344
|
+
}
|
|
345
|
+
const { owner, repository } = reference.repository;
|
|
346
|
+
const number = reference.number;
|
|
347
|
+
const pullRequestName = `${owner}/${repository}/${String(number)}`;
|
|
348
|
+
let client;
|
|
349
|
+
let pullRequest;
|
|
350
|
+
try {
|
|
351
|
+
client = createGitHubClient(out, config.host);
|
|
352
|
+
pullRequest = await client.getPullRequestSlim(owner, repository, number);
|
|
353
|
+
}
|
|
354
|
+
catch (error) {
|
|
355
|
+
if (error instanceof GitHubNotFoundError) {
|
|
356
|
+
out.error(`PR ${pullRequestName} not found`);
|
|
357
|
+
return FAILURE;
|
|
358
|
+
}
|
|
359
|
+
if (!(error instanceof GitHubAPIError))
|
|
360
|
+
throw error;
|
|
361
|
+
out.error(`could not read PR ${pullRequestName}: ${describeApiError(error)}`);
|
|
362
|
+
return FAILURE;
|
|
363
|
+
}
|
|
364
|
+
if (pullRequest.state === 'MERGED') {
|
|
365
|
+
out.error(`PR #${String(number)} is already merged`);
|
|
366
|
+
return FAILURE;
|
|
367
|
+
}
|
|
368
|
+
if (pullRequest.state === 'CLOSED') {
|
|
369
|
+
out.error(`PR #${String(number)} is closed`);
|
|
370
|
+
return FAILURE;
|
|
371
|
+
}
|
|
372
|
+
if (pullRequest.mergeable === 'CONFLICTING' && !input.admin) {
|
|
373
|
+
out.error(`PR #${String(number)} has conflicts that must be resolved\nto try a forced merge, add --admin`);
|
|
374
|
+
return FAILURE;
|
|
375
|
+
}
|
|
376
|
+
const releaseBranch = requireBranchSetting(out, getReleaseBranch(config, owner, repository), 'release', owner, repository);
|
|
377
|
+
if (releaseBranch === undefined)
|
|
378
|
+
return FAILURE;
|
|
379
|
+
if (pullRequest.base_ref !== releaseBranch) {
|
|
380
|
+
out.error(`the base branch of PR #${String(number)} does not match release_branch\nbase: ${pullRequest.base_ref}\nrelease_branch: ${releaseBranch}`);
|
|
381
|
+
return FAILURE;
|
|
382
|
+
}
|
|
383
|
+
const headBranch = pullRequest.head_ref;
|
|
384
|
+
const operation = { verb: 'merge', target: `PR ${pullRequestName} (${headBranch} -> ${pullRequest.base_ref}, merge commit)` };
|
|
385
|
+
if (input.dry_run) {
|
|
386
|
+
out.planned(operation);
|
|
387
|
+
return 0;
|
|
388
|
+
}
|
|
389
|
+
try {
|
|
390
|
+
await client.mergePullRequest(owner, repository, number, 'merge');
|
|
391
|
+
}
|
|
392
|
+
catch (error) {
|
|
393
|
+
if (!(error instanceof GitHubAPIError))
|
|
394
|
+
throw error;
|
|
395
|
+
out.error(`could not merge PR ${pullRequestName}: ${describeApiError(error)}`);
|
|
396
|
+
return FAILURE;
|
|
397
|
+
}
|
|
398
|
+
out.done(operation);
|
|
399
|
+
if (input.delete_branch) {
|
|
400
|
+
try {
|
|
401
|
+
await client.deleteBranch(owner, repository, headBranch);
|
|
402
|
+
out.done({ verb: 'delete', target: `remote branch ${headBranch} in ${owner}/${repository}` });
|
|
403
|
+
}
|
|
404
|
+
catch (error) {
|
|
405
|
+
if (!(error instanceof GitHubAPIError))
|
|
406
|
+
throw error;
|
|
407
|
+
out.warning(`deleting remote branch ${headBranch} failed: ${describeApiError(error)}`);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return 0;
|
|
411
|
+
},
|
|
412
|
+
});
|
|
413
|
+
export const RELEASE_COMMANDS = [preflight, create, merge];
|
|
414
|
+
//# sourceMappingURL=release.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// `--show-repo` の出力。解決したリポジトリと解決元の 2 行。
|
|
2
|
+
import { repositoryFullName } from '../domain/repository-resolver.js';
|
|
3
|
+
export function formatResolvedRepository(resolved) {
|
|
4
|
+
const source = resolved.source === 'explicit' ? 'explicit' : `current-git (${resolved.remoteName ?? ''})`;
|
|
5
|
+
return `resolved: ${repositoryFullName(resolved.repository)}\nsource: ${source}\n`;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=repository-display.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PolicyMode } from '../domain/repository-policy.js';
|
|
2
|
+
import type { RepositoryReference, ResolvedRepository } from '../domain/repository-resolver.js';
|
|
3
|
+
import type { CommandIo } from './command-definition.js';
|
|
4
|
+
/**
|
|
5
|
+
今の git remote からリポジトリを解決する。git の外・remote 無しは undefined
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveCurrentRepository(cwd: string): ResolvedRepository | undefined;
|
|
8
|
+
/**
|
|
9
|
+
`--repo` と今の git remote を方針(reject か warn)に従って比べる。
|
|
10
|
+
続けてよいなら、明示値から採ったリポジトリ(`--repo` が無ければ undefined)を返す。
|
|
11
|
+
止めるときは、stderr に行を書いて CommandExit(1) を投げる。warn の警告は stderr に書いて続ける
|
|
12
|
+
*/
|
|
13
|
+
export declare function requireRepositoryMatch(mode: PolicyMode, explicit: string | undefined, io: Readonly<CommandIo>, cwd: string): RepositoryReference | undefined;
|
|
14
|
+
//# sourceMappingURL=repository-match.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// グローバルの `--repo` と、今の git remote のリポジトリの食い違いを扱う(Python の `require_repo_match`)。
|
|
2
|
+
// 判定は domain/repository-policy.ts の applyRepositoryPolicy に任せ、ここは git の解決と行の出力、止めるときの終了コードだけを行う。
|
|
3
|
+
import { applyRepositoryPolicy } from '../domain/repository-policy.js';
|
|
4
|
+
import { AmbiguousRepositoryError, resolveRepository } from '../domain/repository-resolver.js';
|
|
5
|
+
import { gitRunnerFor } from '../infra/git.js';
|
|
6
|
+
import { CommandExit } from './command-definition.js';
|
|
7
|
+
/**
|
|
8
|
+
今の git remote からリポジトリを解決する。git の外・remote 無しは undefined
|
|
9
|
+
*/
|
|
10
|
+
export function resolveCurrentRepository(cwd) {
|
|
11
|
+
try {
|
|
12
|
+
return resolveRepository(undefined, gitRunnerFor(cwd));
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (error instanceof AmbiguousRepositoryError)
|
|
16
|
+
return undefined;
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
`--repo` と今の git remote を方針(reject か warn)に従って比べる。
|
|
22
|
+
続けてよいなら、明示値から採ったリポジトリ(`--repo` が無ければ undefined)を返す。
|
|
23
|
+
止めるときは、stderr に行を書いて CommandExit(1) を投げる。warn の警告は stderr に書いて続ける
|
|
24
|
+
*/
|
|
25
|
+
export function requireRepositoryMatch(mode, explicit, io, cwd) {
|
|
26
|
+
const outcome = applyRepositoryPolicy({ explicit, resolved: resolveCurrentRepository(cwd), mode });
|
|
27
|
+
for (const line of outcome.stderr)
|
|
28
|
+
io.stderr(`${line}\n`);
|
|
29
|
+
if (outcome.kind === 'exit')
|
|
30
|
+
throw new CommandExit(outcome.exitCode);
|
|
31
|
+
return outcome.adopted;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=repository-match.js.map
|