bdy 1.25.38-dev → 1.25.38-dev-pr
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/distTs/package.json +2 -1
- package/distTs/src/api/client.js +191 -1
- package/distTs/src/autocomplete.js +90 -0
- package/distTs/src/cliError.js +5 -0
- package/distTs/src/cliIndex.js +3 -0
- package/distTs/src/command/artifact/downloadDir.js +110 -0
- package/distTs/src/command/autocomplete/install.js +16 -0
- package/distTs/src/command/autocomplete/uninstall.js +16 -0
- package/distTs/src/command/autocomplete.js +14 -0
- package/distTs/src/command/environment/resolve.js +39 -0
- package/distTs/src/command/login.js +1 -1
- package/distTs/src/command/package/create.js +64 -0
- package/distTs/src/command/package/delete.js +38 -0
- package/distTs/src/command/package/docker/login.js +26 -0
- package/distTs/src/command/package/docker.js +11 -0
- package/distTs/src/command/package/download.js +138 -0
- package/distTs/src/command/package/get.js +36 -0
- package/distTs/src/command/package/list.js +31 -0
- package/distTs/src/command/package/publish.js +241 -0
- package/distTs/src/command/package/version/delete.js +39 -0
- package/distTs/src/command/package/version/get.js +45 -0
- package/distTs/src/command/package/version/list.js +47 -0
- package/distTs/src/command/package/version.js +16 -0
- package/distTs/src/command/package.js +26 -0
- package/distTs/src/command/pipeline/run/apply.js +62 -0
- package/distTs/src/command/pr/comment/add.js +66 -0
- package/distTs/src/command/pr/comment/list.js +169 -0
- package/distTs/src/command/pr/comment/status.js +48 -0
- package/distTs/src/command/pr/comment.js +19 -0
- package/distTs/src/command/pr/create.js +43 -0
- package/distTs/src/command/pr/diff.js +227 -0
- package/distTs/src/command/pr/file/list.js +124 -0
- package/distTs/src/command/pr/file/mark.js +45 -0
- package/distTs/src/command/pr/file.js +16 -0
- package/distTs/src/command/pr/get.js +29 -0
- package/distTs/src/command/pr/list.js +79 -0
- package/distTs/src/command/pr/merge.js +66 -0
- package/distTs/src/command/pr/review/request.js +29 -0
- package/distTs/src/command/pr/review/start.js +29 -0
- package/distTs/src/command/pr/review/verdict.js +81 -0
- package/distTs/src/command/pr/review.js +18 -0
- package/distTs/src/command/pr/shared.js +595 -0
- package/distTs/src/command/pr/state.js +38 -0
- package/distTs/src/command/pr/summary.js +316 -0
- package/distTs/src/command/pr/update.js +54 -0
- package/distTs/src/command/pr/updateBranch.js +22 -0
- package/distTs/src/command/pr/versions.js +42 -0
- package/distTs/src/command/pr.js +39 -0
- package/distTs/src/command/scrape/validation.js +154 -0
- package/distTs/src/command/scrape.js +144 -0
- package/distTs/src/command/suiteLink.js +14 -0
- package/distTs/src/command/tests/visual/result/download.js +31 -0
- package/distTs/src/command/tests/visual/result/get.js +68 -0
- package/distTs/src/command/tests/visual/result/list.js +49 -0
- package/distTs/src/command/tests/visual/result.js +23 -0
- package/distTs/src/command/tests/visual/session/get.js +70 -0
- package/distTs/src/command/tests/visual/session/list.js +69 -0
- package/distTs/src/command/tests/visual/session/open.js +22 -0
- package/distTs/src/command/tests/visual/session/reviewUrl.js +37 -0
- package/distTs/src/command/tests/visual/session/update.js +26 -0
- package/distTs/src/command/tests/visual/shared/context.js +144 -0
- package/distTs/src/command/tests/visual/shared/diffRegions.js +172 -0
- package/distTs/src/command/tests/visual/shared/format.js +21 -0
- package/distTs/src/command/tests/visual/shared/lookup.js +107 -0
- package/distTs/src/command/tests/visual/shared/options.js +90 -0
- package/distTs/src/command/tests/visual/shared/review.js +146 -0
- package/distTs/src/command/tests/visual/shared/reviewUrl.js +62 -0
- package/distTs/src/command/tests/visual/shared/session.js +217 -0
- package/distTs/src/command/tests/visual/snapshot/get.js +46 -0
- package/distTs/src/command/tests/visual/snapshot/list.js +68 -0
- package/distTs/src/command/tests/visual/snapshot/open.js +26 -0
- package/distTs/src/command/tests/visual/snapshot/reviewUrl.js +48 -0
- package/distTs/src/command/tests/visual/snapshot.js +28 -0
- package/distTs/src/command/tests/visual/suite/create.js +38 -0
- package/distTs/src/command/tests/visual/suite/delete.js +29 -0
- package/distTs/src/command/tests/visual/suite/get.js +43 -0
- package/distTs/src/command/tests/visual/suite/list.js +35 -0
- package/distTs/src/command/tests/visual/suite/open.js +20 -0
- package/distTs/src/command/tests/visual/suite/update.js +47 -0
- package/distTs/src/command/tests/visual/suite.js +30 -0
- package/distTs/src/command/ut/upload.js +86 -0
- package/distTs/src/command/ut.js +12 -0
- package/distTs/src/command/vt/close.js +27 -0
- package/distTs/src/command/vt/compare/validation.js +46 -0
- package/distTs/src/command/vt/compare.js +100 -0
- package/distTs/src/command/vt/exec.js +82 -0
- package/distTs/src/command/vt/installBrowser.js +20 -0
- package/distTs/src/command/vt/shared/validation.js +145 -0
- package/distTs/src/command/vt/storybook.js +138 -0
- package/distTs/src/command/vt.js +20 -0
- package/distTs/src/command/yaml/agents.js +88 -0
- package/distTs/src/command/yaml/init.js +110 -0
- package/distTs/src/main.js +190 -0
- package/distTs/src/output/pipeline.js +54 -56
- package/distTs/src/output.js +72 -22
- package/distTs/src/texts.js +450 -1
- package/distTs/src/tunnel/output/interactive/tunnel.js +14 -10
- package/distTs/src/tunnel/output/noninteractive/tunnel.js +3 -1
- package/distTs/src/types/options.js +2 -0
- package/distTs/src/types/scrape.js +2 -0
- package/distTs/src/types/visualTests.js +2 -0
- package/distTs/src/utils.js +133 -3
- package/package.json +2 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
10
|
+
const shared_1 = require("../shared");
|
|
11
|
+
const summary_1 = require("../summary");
|
|
12
|
+
const commandPrFileList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_PR_FILE_LIST, {
|
|
13
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_READ],
|
|
14
|
+
examples: texts_1.EXAMPLE_PR_FILE_LIST,
|
|
15
|
+
});
|
|
16
|
+
commandPrFileList.alias('ls');
|
|
17
|
+
(0, shared_1.addPrOptions)(commandPrFileList, true);
|
|
18
|
+
commandPrFileList.option('--since-review', texts_1.OPTION_PR_FILES_SINCE_REVIEW);
|
|
19
|
+
commandPrFileList.option('--must-review', texts_1.OPTION_PR_FILES_MUST_REVIEW);
|
|
20
|
+
commandPrFileList.option('--unclear', texts_1.OPTION_PR_FILES_UNCLEAR);
|
|
21
|
+
commandPrFileList.option('--batch <k>', texts_1.OPTION_PR_FILES_BATCH);
|
|
22
|
+
commandPrFileList.argument('[N]', texts_1.OPTION_PR_NUMBER);
|
|
23
|
+
commandPrFileList.action(async (n, options) => {
|
|
24
|
+
const filters = [
|
|
25
|
+
options.sinceReview,
|
|
26
|
+
options.mustReview,
|
|
27
|
+
options.unclear,
|
|
28
|
+
options.batch !== undefined,
|
|
29
|
+
].filter(Boolean);
|
|
30
|
+
if (filters.length > 1)
|
|
31
|
+
throw new cliError_1.default('usage_error', texts_1.ERR_PR_FILE_FILTERS);
|
|
32
|
+
let batch;
|
|
33
|
+
if (options.batch !== undefined) {
|
|
34
|
+
if (!/^[1-9]\d*$/.test(options.batch))
|
|
35
|
+
throw new cliError_1.default('usage_error', texts_1.ERR_PR_BATCH);
|
|
36
|
+
batch = Number(options.batch);
|
|
37
|
+
}
|
|
38
|
+
const version = (0, shared_1.parseRev)(options.rev);
|
|
39
|
+
const scope = (0, shared_1.prScope)(options);
|
|
40
|
+
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
41
|
+
let result;
|
|
42
|
+
let files;
|
|
43
|
+
if (options.mustReview || batch !== undefined) {
|
|
44
|
+
result = await (0, shared_1.fetchMustReview)(scope, number, version);
|
|
45
|
+
files = result.files || [];
|
|
46
|
+
if (batch !== undefined) {
|
|
47
|
+
const batches = (0, shared_1.buildBatches)(files);
|
|
48
|
+
if (batches.length === 0) {
|
|
49
|
+
const tokens = files.reduce((sum, f) => sum + (0, shared_1.tokensOf)(f), 0);
|
|
50
|
+
throw new cliError_1.default('usage_error', (0, texts_1.ERR_PR_NO_BATCHES)(files.length, tokens));
|
|
51
|
+
}
|
|
52
|
+
if (batch > batches.length) {
|
|
53
|
+
throw new cliError_1.default('usage_error', (0, texts_1.ERR_PR_BATCH_RANGE)(batch, batches.length));
|
|
54
|
+
}
|
|
55
|
+
files = batches[batch - 1].files;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (options.unclear) {
|
|
59
|
+
result = await (0, shared_1.fetchAllFiles)(scope, number, {
|
|
60
|
+
version,
|
|
61
|
+
review_priority: utils_1.PR_REVIEW_PRIORITY.UNCLEAR,
|
|
62
|
+
sort: utils_1.PR_FILES_SORT.REVIEW_ORDER,
|
|
63
|
+
});
|
|
64
|
+
files = result.files || [];
|
|
65
|
+
}
|
|
66
|
+
else if (options.sinceReview) {
|
|
67
|
+
result = await (0, shared_1.fetchAllFiles)(scope, number, { version, since_review: true });
|
|
68
|
+
files = result.files || [];
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
result = await (0, shared_1.fetchAllFiles)(scope, number, { version });
|
|
72
|
+
files = result.files || [];
|
|
73
|
+
}
|
|
74
|
+
if (options.format === 'json') {
|
|
75
|
+
output_1.default.json(files);
|
|
76
|
+
output_1.default.exitNormal();
|
|
77
|
+
}
|
|
78
|
+
if (version) {
|
|
79
|
+
const pr = await scope.client.getPullRequest(scope.workspace, scope.project, number);
|
|
80
|
+
(0, shared_1.noteVersionBehind)(pr?.version, result.version);
|
|
81
|
+
}
|
|
82
|
+
if (files.length === 0)
|
|
83
|
+
output_1.default.exitNormal(texts_1.TXT_PR_FILES_NOT_FOUND);
|
|
84
|
+
// the reason a file is on the since-review list needs the threads not CLOSED
|
|
85
|
+
let byPath = new Map();
|
|
86
|
+
if (options.sinceReview) {
|
|
87
|
+
const threads = await (0, shared_1.fetchAllThreads)(scope, number, { version: result.version });
|
|
88
|
+
byPath = (0, summary_1.threadsByPath)(threads.threads || []);
|
|
89
|
+
}
|
|
90
|
+
const data = [
|
|
91
|
+
['STATUS', '+/-', 'VIEWED', 'CHANGED', 'PRIORITY', 'TYPE', 'SIZE/TOKENS', 'PATH', 'SYMBOLS'],
|
|
92
|
+
];
|
|
93
|
+
const sorted = (0, shared_1.sortFilesForReading)(files);
|
|
94
|
+
for (const file of sorted) {
|
|
95
|
+
const symbols = file.analysis?.changed_symbols || [];
|
|
96
|
+
const flags = [];
|
|
97
|
+
if (file.analysis?.has_only_duplicated_hunks)
|
|
98
|
+
flags.push('only repeated changes');
|
|
99
|
+
if (options.sinceReview) {
|
|
100
|
+
const reason = (0, summary_1.sinceReviewReason)(file, byPath);
|
|
101
|
+
if (reason)
|
|
102
|
+
flags.push(reason);
|
|
103
|
+
}
|
|
104
|
+
const path = file.previous_file_name
|
|
105
|
+
? `${file.file_name} ← ${file.previous_file_name}`
|
|
106
|
+
: file.file_name;
|
|
107
|
+
data.push([
|
|
108
|
+
(0, shared_1.fileStatusText)(file.status),
|
|
109
|
+
`+${file.additions ?? 0}/-${file.deletions ?? 0}`,
|
|
110
|
+
file.viewed ? output_1.default.getGreenColor('yes') : 'no',
|
|
111
|
+
file.changed_since_review === null || file.changed_since_review === undefined
|
|
112
|
+
? '-'
|
|
113
|
+
: file.changed_since_review ? 'yes' : 'no',
|
|
114
|
+
(0, shared_1.filePriorityText)(file.triage?.review_priority) || '-',
|
|
115
|
+
(0, shared_1.changeTypeText)(file.analysis?.change_type),
|
|
116
|
+
(0, shared_1.fileSizeText)(file),
|
|
117
|
+
flags.length ? `${path} (${flags.join(', ')})` : path,
|
|
118
|
+
symbols.slice(0, 3).map((s) => s.name).join(', ') + (symbols.length > 3 ? ` +${symbols.length - 3}` : ''),
|
|
119
|
+
]);
|
|
120
|
+
}
|
|
121
|
+
output_1.default.table(data, true, true);
|
|
122
|
+
output_1.default.exitNormal();
|
|
123
|
+
});
|
|
124
|
+
exports.default = commandPrFileList;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.commandPrFileUnviewed = exports.commandPrFileViewed = void 0;
|
|
7
|
+
const utils_1 = require("../../../utils");
|
|
8
|
+
const texts_1 = require("../../../texts");
|
|
9
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
+
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
11
|
+
const shared_1 = require("../shared");
|
|
12
|
+
// the API takes up to 500 paths per request
|
|
13
|
+
const CHUNK = 500;
|
|
14
|
+
const markCommand = (viewed) => {
|
|
15
|
+
const command = (0, utils_1.newCommand)(viewed ? 'viewed' : 'unviewed', viewed ? texts_1.DESC_COMMAND_PR_FILE_VIEWED : texts_1.DESC_COMMAND_PR_FILE_UNVIEWED, {
|
|
16
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_WRITE],
|
|
17
|
+
examples: viewed ? texts_1.EXAMPLE_PR_FILE_VIEWED : texts_1.EXAMPLE_PR_FILE_UNVIEWED,
|
|
18
|
+
});
|
|
19
|
+
(0, shared_1.addPrOptions)(command, true);
|
|
20
|
+
// `[N] <path...>`: N is split off in the action
|
|
21
|
+
command.argument('<paths...>', texts_1.OPTION_PR_FILE_PATHS);
|
|
22
|
+
command.usage('[options] [N] <path...>');
|
|
23
|
+
command.action(async (args, options) => {
|
|
24
|
+
const { number: n, rest: paths } = (0, shared_1.splitNumberArgs)(args);
|
|
25
|
+
if (paths.length === 0) {
|
|
26
|
+
throw new cliError_1.default('usage_error', (0, texts_1.ERR_PR_ARGS)('[N] <path...>', args.join(' ')));
|
|
27
|
+
}
|
|
28
|
+
const version = (0, shared_1.parseRev)(options.rev);
|
|
29
|
+
const scope = (0, shared_1.prScope)(options);
|
|
30
|
+
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
31
|
+
const files = [];
|
|
32
|
+
let shown = version;
|
|
33
|
+
for (let i = 0; i < paths.length; i += CHUNK) {
|
|
34
|
+
const result = await scope.client.markPullRequestFilesViewed(scope.workspace, scope.project, number, { paths: paths.slice(i, i + CHUNK), viewed, version });
|
|
35
|
+
shown = result?.version ?? shown;
|
|
36
|
+
files.push(...(result?.files || []));
|
|
37
|
+
}
|
|
38
|
+
output_1.default.exitResult(options.format === 'json', { version: shown, files }, viewed
|
|
39
|
+
? (0, texts_1.TXT_PR_FILES_VIEWED)(paths.length, shown)
|
|
40
|
+
: (0, texts_1.TXT_PR_FILES_UNVIEWED)(paths.length, shown));
|
|
41
|
+
});
|
|
42
|
+
return command;
|
|
43
|
+
};
|
|
44
|
+
exports.commandPrFileViewed = markCommand(true);
|
|
45
|
+
exports.commandPrFileUnviewed = markCommand(false);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const list_1 = __importDefault(require("./file/list"));
|
|
9
|
+
const mark_1 = require("./file/mark");
|
|
10
|
+
const commandPrFile = (0, utils_1.newCommand)('file', texts_1.DESC_COMMAND_PR_FILE, {
|
|
11
|
+
examples: texts_1.EXAMPLE_PR_FILE,
|
|
12
|
+
});
|
|
13
|
+
commandPrFile.addCommand(list_1.default);
|
|
14
|
+
commandPrFile.addCommand(mark_1.commandPrFileViewed);
|
|
15
|
+
commandPrFile.addCommand(mark_1.commandPrFileUnviewed);
|
|
16
|
+
exports.default = commandPrFile;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const shared_1 = require("./shared");
|
|
10
|
+
const summary_1 = require("./summary");
|
|
11
|
+
const commandPrGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_PR_GET, {
|
|
12
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_READ],
|
|
13
|
+
examples: texts_1.EXAMPLE_PR_GET,
|
|
14
|
+
});
|
|
15
|
+
(0, shared_1.addPrOptions)(commandPrGet, true);
|
|
16
|
+
commandPrGet.option('--since-review', texts_1.OPTION_PR_SINCE_REVIEW_GET);
|
|
17
|
+
commandPrGet.argument('[N]', texts_1.OPTION_PR_NUMBER);
|
|
18
|
+
commandPrGet.action(async (n, options) => {
|
|
19
|
+
const version = (0, shared_1.parseRev)(options.rev);
|
|
20
|
+
const scope = (0, shared_1.prScope)(options);
|
|
21
|
+
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
22
|
+
await (0, summary_1.printSummary)(scope, number, {
|
|
23
|
+
rev: version,
|
|
24
|
+
sinceReview: !!options.sinceReview,
|
|
25
|
+
json: options.format === 'json',
|
|
26
|
+
});
|
|
27
|
+
output_1.default.exitNormal();
|
|
28
|
+
});
|
|
29
|
+
exports.default = commandPrGet;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../input"));
|
|
10
|
+
const cliError_1 = __importDefault(require("../../cliError"));
|
|
11
|
+
const shared_1 = require("./shared");
|
|
12
|
+
const commandPrList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_PR_LIST, {
|
|
13
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_READ],
|
|
14
|
+
examples: texts_1.EXAMPLE_PR_LIST,
|
|
15
|
+
});
|
|
16
|
+
commandPrList.alias('ls');
|
|
17
|
+
(0, shared_1.addPrOptions)(commandPrList);
|
|
18
|
+
commandPrList.option('--state <state>', texts_1.OPTION_PR_STATE);
|
|
19
|
+
commandPrList.option('--author <login|me>', texts_1.OPTION_PR_AUTHOR);
|
|
20
|
+
commandPrList.option('--reviewer <login|me>', texts_1.OPTION_PR_REVIEWER);
|
|
21
|
+
commandPrList.option('--head <branch>', texts_1.OPTION_PR_HEAD_FILTER);
|
|
22
|
+
commandPrList.option('--base <branch>', texts_1.OPTION_PR_BASE_FILTER);
|
|
23
|
+
commandPrList.option('--page <number>', texts_1.OPTION_REST_API_PAGE);
|
|
24
|
+
commandPrList.option('--per-page <number>', texts_1.OPTION_PR_PER_PAGE);
|
|
25
|
+
// `me` is the invoker; the API takes a username or an e-mail
|
|
26
|
+
const login = async (scope, value) => {
|
|
27
|
+
if (value !== 'me')
|
|
28
|
+
return value;
|
|
29
|
+
const user = await scope.client.getInvoker();
|
|
30
|
+
return user?.email;
|
|
31
|
+
};
|
|
32
|
+
commandPrList.action(async (options) => {
|
|
33
|
+
let state;
|
|
34
|
+
if (options.state) {
|
|
35
|
+
state = String(options.state).toUpperCase();
|
|
36
|
+
if (!Object.values(utils_1.PR_STATE).includes(state)) {
|
|
37
|
+
throw new cliError_1.default('usage_error', texts_1.ERR_PR_STATE);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const page = options.page ? input_1.default.restApiPage(options.page) : undefined;
|
|
41
|
+
const perPage = options.perPage
|
|
42
|
+
? input_1.default.restApiPerPage(options.perPage)
|
|
43
|
+
: undefined;
|
|
44
|
+
const scope = (0, shared_1.prScope)(options);
|
|
45
|
+
const result = await scope.client.getPullRequests(scope.workspace, scope.project, {
|
|
46
|
+
state,
|
|
47
|
+
author: await login(scope, options.author),
|
|
48
|
+
reviewer: await login(scope, options.reviewer),
|
|
49
|
+
head: options.head,
|
|
50
|
+
base: options.base,
|
|
51
|
+
page,
|
|
52
|
+
per_page: perPage,
|
|
53
|
+
});
|
|
54
|
+
const prs = result?.pull_requests || [];
|
|
55
|
+
if (options.format === 'json') {
|
|
56
|
+
output_1.default.json(prs);
|
|
57
|
+
output_1.default.exitNormal();
|
|
58
|
+
}
|
|
59
|
+
if (prs.length === 0)
|
|
60
|
+
output_1.default.exitNormal(texts_1.TXT_PR_NOT_FOUND);
|
|
61
|
+
const data = [
|
|
62
|
+
['#', 'TITLE', 'STATE', 'MERGEABLE', 'BRANCHES', 'AUTHOR', 'VERSION', 'UPDATED'],
|
|
63
|
+
];
|
|
64
|
+
for (const pr of prs) {
|
|
65
|
+
data.push([
|
|
66
|
+
String(pr.number ?? '-'),
|
|
67
|
+
pr.title || '-',
|
|
68
|
+
(0, shared_1.prStateText)(pr),
|
|
69
|
+
(0, shared_1.mergeableText)(pr.mergeable),
|
|
70
|
+
pr.head ? `${pr.base} ← ${pr.head}` : '-',
|
|
71
|
+
pr.author ? (0, shared_1.memberName)(pr.author) : '-',
|
|
72
|
+
pr.version ? `v${pr.version}` : '-',
|
|
73
|
+
(0, shared_1.formatDate)(pr.last_update_date || pr.create_date),
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
76
|
+
output_1.default.table(data, true, true);
|
|
77
|
+
output_1.default.exitNormal();
|
|
78
|
+
});
|
|
79
|
+
exports.default = commandPrList;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const cliError_1 = __importDefault(require("../../cliError"));
|
|
10
|
+
const shared_1 = require("./shared");
|
|
11
|
+
const commandPrMerge = (0, utils_1.newCommand)('merge', texts_1.DESC_COMMAND_PR_MERGE, {
|
|
12
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_WRITE],
|
|
13
|
+
examples: texts_1.EXAMPLE_PR_MERGE,
|
|
14
|
+
});
|
|
15
|
+
(0, shared_1.addPrOptions)(commandPrMerge, true);
|
|
16
|
+
commandPrMerge.option('--method <method>', texts_1.OPTION_PR_MERGE_METHOD);
|
|
17
|
+
commandPrMerge.option('--delete-branch', texts_1.OPTION_PR_DELETE_BRANCH);
|
|
18
|
+
commandPrMerge.option('--message <text|@path|->', texts_1.OPTION_PR_MERGE_MESSAGE);
|
|
19
|
+
commandPrMerge.option('--no-review', texts_1.OPTION_PR_NO_REVIEW);
|
|
20
|
+
commandPrMerge.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
|
|
21
|
+
commandPrMerge.argument('[N]', texts_1.OPTION_PR_NUMBER);
|
|
22
|
+
commandPrMerge.action(async (n, options) => {
|
|
23
|
+
const method = String(options.method || utils_1.PR_MERGE_METHOD.MERGE).toUpperCase();
|
|
24
|
+
if (!Object.values(utils_1.PR_MERGE_METHOD).includes(method)) {
|
|
25
|
+
throw new cliError_1.default('usage_error', texts_1.ERR_PR_MERGE_METHOD);
|
|
26
|
+
}
|
|
27
|
+
const rev = (0, shared_1.parseRev)(options.rev);
|
|
28
|
+
const commitMessage = (0, shared_1.readText)(options.message, false);
|
|
29
|
+
const json = options.format === 'json';
|
|
30
|
+
const scope = (0, shared_1.prScope)(options);
|
|
31
|
+
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
32
|
+
const { client, workspace, project } = scope;
|
|
33
|
+
// the version is fixed before the prompt, so a version that appears meanwhile is refused (409)
|
|
34
|
+
const pr = await client.getPullRequest(workspace, project, number);
|
|
35
|
+
const version = rev ?? pr.version;
|
|
36
|
+
if (!json)
|
|
37
|
+
(0, shared_1.noteVersionBehind)(pr.version, version);
|
|
38
|
+
// -f skips only the prompt; --no-review skips this check
|
|
39
|
+
if (options.review !== false) {
|
|
40
|
+
const result = await client.getPullRequestReviews(workspace, project, number);
|
|
41
|
+
const reviews = result?.reviews || [];
|
|
42
|
+
if (!reviews.some((r) => r.verdict === utils_1.PR_VERDICT.APPROVED)) {
|
|
43
|
+
throw new cliError_1.default('usage_error', texts_1.ERR_PR_NOT_APPROVED);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const confirmed = await output_1.default.confirmDestructive(options.force, (0, texts_1.TXT_PR_MERGE_CONFIRM)(number, version, method), json);
|
|
47
|
+
if (!confirmed)
|
|
48
|
+
output_1.default.exitResult(json, { merged: null });
|
|
49
|
+
let merged;
|
|
50
|
+
try {
|
|
51
|
+
merged = await client.mergePullRequest(workspace, project, number, {
|
|
52
|
+
version,
|
|
53
|
+
method,
|
|
54
|
+
delete_branch: options.deleteBranch ? true : undefined,
|
|
55
|
+
commit_message: commitMessage,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
if ((0, shared_1.isVersionConflict)(err)) {
|
|
60
|
+
throw new cliError_1.default('usage_error', (0, texts_1.TXT_PR_MERGE_VERSION_CONFLICT)(scope.cmd, number, (0, shared_1.conflictVersion)(err)));
|
|
61
|
+
}
|
|
62
|
+
throw err;
|
|
63
|
+
}
|
|
64
|
+
output_1.default.exitResult(json, merged, (0, texts_1.TXT_PR_MERGED)(number, version));
|
|
65
|
+
});
|
|
66
|
+
exports.default = commandPrMerge;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
10
|
+
const shared_1 = require("../shared");
|
|
11
|
+
const commandPrReviewRequest = (0, utils_1.newCommand)('request', texts_1.DESC_COMMAND_PR_REVIEW_REQUEST, {
|
|
12
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_WRITE],
|
|
13
|
+
examples: texts_1.EXAMPLE_PR_REVIEW_REQUEST,
|
|
14
|
+
});
|
|
15
|
+
(0, shared_1.addPrOptions)(commandPrReviewRequest);
|
|
16
|
+
// `[N] <login...>`: N is split off in the action
|
|
17
|
+
commandPrReviewRequest.argument('<logins...>', texts_1.OPTION_PR_REVIEW_LOGINS);
|
|
18
|
+
commandPrReviewRequest.usage('[options] [N] <login...>');
|
|
19
|
+
commandPrReviewRequest.action(async (args, options) => {
|
|
20
|
+
const { number: n, rest: logins } = (0, shared_1.splitNumberArgs)(args);
|
|
21
|
+
if (logins.length === 0) {
|
|
22
|
+
throw new cliError_1.default('usage_error', (0, texts_1.ERR_PR_ARGS)('[N] <login...>', args.join(' ')));
|
|
23
|
+
}
|
|
24
|
+
const scope = (0, shared_1.prScope)(options);
|
|
25
|
+
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
26
|
+
const pr = await scope.client.requestPullRequestReview(scope.workspace, scope.project, number, logins);
|
|
27
|
+
output_1.default.exitResult(options.format === 'json', pr, (0, texts_1.TXT_PR_REVIEW_REQUESTED)(logins.join(', ')));
|
|
28
|
+
});
|
|
29
|
+
exports.default = commandPrReviewRequest;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const shared_1 = require("../shared");
|
|
10
|
+
const summary_1 = require("../summary");
|
|
11
|
+
const commandPrReviewStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_PR_REVIEW_START, {
|
|
12
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_WRITE],
|
|
13
|
+
examples: texts_1.EXAMPLE_PR_REVIEW_START,
|
|
14
|
+
});
|
|
15
|
+
(0, shared_1.addPrOptions)(commandPrReviewStart, true);
|
|
16
|
+
commandPrReviewStart.argument('[N]', texts_1.OPTION_PR_NUMBER);
|
|
17
|
+
commandPrReviewStart.action(async (n, options) => {
|
|
18
|
+
const version = (0, shared_1.parseRev)(options.rev);
|
|
19
|
+
const scope = (0, shared_1.prScope)(options);
|
|
20
|
+
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
21
|
+
// idempotent: an existing review stays as it is
|
|
22
|
+
await scope.client.startPullRequestReview(scope.workspace, scope.project, number, version);
|
|
23
|
+
await (0, summary_1.printSummary)(scope, number, {
|
|
24
|
+
rev: version,
|
|
25
|
+
json: options.format === 'json',
|
|
26
|
+
});
|
|
27
|
+
output_1.default.exitNormal();
|
|
28
|
+
});
|
|
29
|
+
exports.default = commandPrReviewStart;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.commandPrReviewRequestChanges = exports.commandPrReviewApprove = void 0;
|
|
7
|
+
const utils_1 = require("../../../utils");
|
|
8
|
+
const texts_1 = require("../../../texts");
|
|
9
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
+
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
11
|
+
const shared_1 = require("../shared");
|
|
12
|
+
/**
|
|
13
|
+
* The reasons of a refused approval, in a form an agent can act on: the
|
|
14
|
+
* threads not CLOSED, the unviewed MUST_REVIEW files (as the batches holding
|
|
15
|
+
* them when the list is split) and a pending triage.
|
|
16
|
+
*/
|
|
17
|
+
const blockedError = async (scope, number, version, err) => {
|
|
18
|
+
const body = err.body || {};
|
|
19
|
+
const lines = [`${texts_1.ERR_PR_APPROVAL_BLOCKED}: ${err.message}`];
|
|
20
|
+
const threads = body.open_threads || [];
|
|
21
|
+
const threadsCount = body.open_threads_count ?? threads.length;
|
|
22
|
+
if (threadsCount > 0) {
|
|
23
|
+
lines.push(`${(0, texts_1.TXT_PR_APPROVAL_OPEN_THREADS)(threadsCount)}${threads.length ? ` (${threads.join(', ')})` : ''}`);
|
|
24
|
+
lines.push(` ${scope.cmd(`comment ls ${number} --threads${version ? ` --rev v${version}` : ''}`)}`);
|
|
25
|
+
}
|
|
26
|
+
const notViewed = body.must_review_not_viewed || [];
|
|
27
|
+
const notViewedCount = body.must_review_not_viewed_count ?? notViewed.length;
|
|
28
|
+
if (notViewedCount > 0) {
|
|
29
|
+
lines.push((0, texts_1.TXT_PR_APPROVAL_NOT_VIEWED)(notViewedCount));
|
|
30
|
+
const mustReview = await (0, shared_1.fetchMustReview)(scope, number, version).catch(() => null);
|
|
31
|
+
const shown = mustReview?.version ?? version;
|
|
32
|
+
const batches = (0, shared_1.buildBatches)(mustReview?.files || []);
|
|
33
|
+
const missing = new Set((mustReview?.files || []).filter((f) => !f.viewed).map((f) => f.file_name));
|
|
34
|
+
const open = batches.filter((b) => b.files.some((f) => missing.has(f.file_name)));
|
|
35
|
+
if (open.length > 0) {
|
|
36
|
+
lines.push(texts_1.TXT_PR_APPROVAL_BATCHES);
|
|
37
|
+
open.forEach((b) => lines.push(` ${(0, texts_1.TXT_PR_BATCH_LINE)(b.batch, b.files.length, b.tokens, scope.cmd(`file ls ${number} --batch ${b.batch}${shown ? ` --rev v${shown}` : ''}`))}`));
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const paths = missing.size > 0 ? [...missing] : notViewed;
|
|
41
|
+
paths.forEach((path) => lines.push(` ${path}`));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (body.triage_pending)
|
|
45
|
+
lines.push(texts_1.TXT_PR_APPROVAL_TRIAGE_PENDING);
|
|
46
|
+
return new cliError_1.default('usage_error', lines.join('\n'), texts_1.TXT_PR_APPROVAL_FORCE_HINT);
|
|
47
|
+
};
|
|
48
|
+
const verdictCommand = (name, description, examples, verdict) => {
|
|
49
|
+
const command = (0, utils_1.newCommand)(name, description, {
|
|
50
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_WRITE],
|
|
51
|
+
examples,
|
|
52
|
+
});
|
|
53
|
+
(0, shared_1.addPrOptions)(command, true);
|
|
54
|
+
if (verdict === utils_1.PR_VERDICT.APPROVED)
|
|
55
|
+
command.option('--force', texts_1.OPTION_PR_APPROVE_FORCE);
|
|
56
|
+
command.argument('[N]', texts_1.OPTION_PR_NUMBER);
|
|
57
|
+
command.action(async (n, options) => {
|
|
58
|
+
const version = (0, shared_1.parseRev)(options.rev);
|
|
59
|
+
const scope = (0, shared_1.prScope)(options);
|
|
60
|
+
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
61
|
+
let review;
|
|
62
|
+
try {
|
|
63
|
+
review = await scope.client.submitPullRequestVerdict(scope.workspace, scope.project, number, { verdict, version, force: options.force ? true : undefined });
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
if ((0, shared_1.isVersionConflict)(err)) {
|
|
67
|
+
throw new cliError_1.default('usage_error', (0, texts_1.TXT_PR_VERSION_CONFLICT)(scope.cmd, number, (0, shared_1.conflictVersion)(err)));
|
|
68
|
+
}
|
|
69
|
+
if (err instanceof cliError_1.default && err.status === 400 && err.body && (err.body.open_threads_count !== undefined ||
|
|
70
|
+
err.body.must_review_not_viewed_count !== undefined ||
|
|
71
|
+
err.body.triage_pending !== undefined)) {
|
|
72
|
+
throw await blockedError(scope, number, version, err);
|
|
73
|
+
}
|
|
74
|
+
throw err;
|
|
75
|
+
}
|
|
76
|
+
output_1.default.exitResult(options.format === 'json', review, (0, texts_1.TXT_PR_REVIEW_VERDICT)(review?.verdict ?? verdict, review?.version ?? version));
|
|
77
|
+
});
|
|
78
|
+
return command;
|
|
79
|
+
};
|
|
80
|
+
exports.commandPrReviewApprove = verdictCommand('approve', texts_1.DESC_COMMAND_PR_REVIEW_APPROVE, texts_1.EXAMPLE_PR_REVIEW_APPROVE, utils_1.PR_VERDICT.APPROVED);
|
|
81
|
+
exports.commandPrReviewRequestChanges = verdictCommand('request-changes', texts_1.DESC_COMMAND_PR_REVIEW_REQUEST_CHANGES, texts_1.EXAMPLE_PR_REVIEW_REQUEST_CHANGES, utils_1.PR_VERDICT.CHANGE_REQUESTED);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const start_1 = __importDefault(require("./review/start"));
|
|
9
|
+
const verdict_1 = require("./review/verdict");
|
|
10
|
+
const request_1 = __importDefault(require("./review/request"));
|
|
11
|
+
const commandPrReview = (0, utils_1.newCommand)('review', texts_1.DESC_COMMAND_PR_REVIEW, {
|
|
12
|
+
examples: texts_1.EXAMPLE_PR_REVIEW,
|
|
13
|
+
});
|
|
14
|
+
commandPrReview.addCommand(start_1.default);
|
|
15
|
+
commandPrReview.addCommand(verdict_1.commandPrReviewApprove);
|
|
16
|
+
commandPrReview.addCommand(verdict_1.commandPrReviewRequestChanges);
|
|
17
|
+
commandPrReview.addCommand(request_1.default);
|
|
18
|
+
exports.default = commandPrReview;
|