@microsoft/vscode-azext-github 1.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/LICENSE.md +21 -0
- package/README.md +7 -0
- package/out/src/GitHubContext.d.ts +9 -0
- package/out/src/GitHubContext.js +7 -0
- package/out/src/constants.d.ts +4 -0
- package/out/src/constants.js +13 -0
- package/out/src/createOctokitClient.d.ts +9 -0
- package/out/src/createOctokitClient.js +36 -0
- package/out/src/extensionVariables.d.ts +13 -0
- package/out/src/extensionVariables.js +43 -0
- package/out/src/index.d.ts +15 -0
- package/out/src/index.js +39 -0
- package/out/src/tree/ActionItem.d.ts +19 -0
- package/out/src/tree/ActionItem.js +81 -0
- package/out/src/tree/ActionsItemBase.d.ts +59 -0
- package/out/src/tree/ActionsItemBase.js +114 -0
- package/out/src/tree/JobItem.d.ts +16 -0
- package/out/src/tree/JobItem.js +51 -0
- package/out/src/tree/StepItem.d.ts +15 -0
- package/out/src/tree/StepItem.js +33 -0
- package/out/src/utils/actionUtils.d.ts +35 -0
- package/out/src/utils/actionUtils.js +128 -0
- package/out/src/utils/getGitHubAccessToken.d.ts +1 -0
- package/out/src/utils/getGitHubAccessToken.js +41 -0
- package/out/src/utils/gitHubUrlParse.d.ts +23 -0
- package/out/src/utils/gitHubUrlParse.js +23 -0
- package/out/src/wizard/GitHubBranchListStep.d.ts +13 -0
- package/out/src/wizard/GitHubBranchListStep.js +71 -0
- package/out/src/wizard/GitHubOrgListStep.d.ts +11 -0
- package/out/src/wizard/GitHubOrgListStep.js +52 -0
- package/out/src/wizard/GitHubRepositoryListStep.d.ts +13 -0
- package/out/src/wizard/GitHubRepositoryListStep.js +77 -0
- package/out/src/wrappers/getActions.d.ts +9 -0
- package/out/src/wrappers/getActions.js +28 -0
- package/out/src/wrappers/getAuthenticatedUser.d.ts +7 -0
- package/out/src/wrappers/getAuthenticatedUser.js +28 -0
- package/out/src/wrappers/getBranches.d.ts +11 -0
- package/out/src/wrappers/getBranches.js +28 -0
- package/out/src/wrappers/getJobs.d.ts +10 -0
- package/out/src/wrappers/getJobs.js +28 -0
- package/out/src/wrappers/getOrgs.d.ts +7 -0
- package/out/src/wrappers/getOrgs.js +28 -0
- package/out/src/wrappers/getRepositories.d.ts +16 -0
- package/out/src/wrappers/getRepositories.js +38 -0
- package/package.json +53 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { TreeItemIconPath } from "@microsoft/vscode-azext-utils";
|
|
2
|
+
import { ActionWorkflowRuns } from "../wrappers/getActions";
|
|
3
|
+
import { Job, JobStep } from "../wrappers/getJobs";
|
|
4
|
+
/**
|
|
5
|
+
* GitHub 'Check Run' - final conclusion of the check
|
|
6
|
+
* https://developer.github.com/v3/checks/runs/#parameters
|
|
7
|
+
*/
|
|
8
|
+
export declare enum Conclusion {
|
|
9
|
+
Success = "success",
|
|
10
|
+
Failure = "failure",
|
|
11
|
+
Skipped = "skipped",
|
|
12
|
+
Cancelled = "cancelled"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* GitHub 'Check Run' - current status of the check
|
|
16
|
+
*/
|
|
17
|
+
export declare enum Status {
|
|
18
|
+
Queued = "queued",
|
|
19
|
+
InProgress = "in_progress",
|
|
20
|
+
Completed = "completed"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get a tree item description based on its Job-related status.
|
|
24
|
+
*
|
|
25
|
+
* Note: Typically does not need to be called directly by client extensions
|
|
26
|
+
* unless implementing a custom experience.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getJobBasedDescription(data: Job | JobStep): string;
|
|
29
|
+
/**
|
|
30
|
+
* Select an icon based on its Action-related status.
|
|
31
|
+
*
|
|
32
|
+
* Note: Typically does not need to be called directly by client extensions
|
|
33
|
+
* unless implementing a custom experience.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getActionBasedIconPath(data: ActionWorkflowRuns | Job | JobStep): TreeItemIconPath;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getActionBasedIconPath = exports.getJobBasedDescription = exports.Status = exports.Conclusion = void 0;
|
|
8
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
9
|
+
const dayjs = require("dayjs");
|
|
10
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
11
|
+
const relativeTime = require("dayjs/plugin/relativeTime");
|
|
12
|
+
const vscode_1 = require("vscode");
|
|
13
|
+
dayjs.extend(relativeTime);
|
|
14
|
+
/**
|
|
15
|
+
* GitHub 'Check Run' - final conclusion of the check
|
|
16
|
+
* https://developer.github.com/v3/checks/runs/#parameters
|
|
17
|
+
*/
|
|
18
|
+
var Conclusion;
|
|
19
|
+
(function (Conclusion) {
|
|
20
|
+
Conclusion["Success"] = "success";
|
|
21
|
+
Conclusion["Failure"] = "failure";
|
|
22
|
+
Conclusion["Skipped"] = "skipped";
|
|
23
|
+
Conclusion["Cancelled"] = "cancelled";
|
|
24
|
+
})(Conclusion || (exports.Conclusion = Conclusion = {}));
|
|
25
|
+
/**
|
|
26
|
+
* GitHub 'Check Run' - current status of the check
|
|
27
|
+
*/
|
|
28
|
+
var Status;
|
|
29
|
+
(function (Status) {
|
|
30
|
+
Status["Queued"] = "queued";
|
|
31
|
+
Status["InProgress"] = "in_progress";
|
|
32
|
+
Status["Completed"] = "completed";
|
|
33
|
+
})(Status || (exports.Status = Status = {}));
|
|
34
|
+
/**
|
|
35
|
+
* Get a tree item description based on its Job-related status.
|
|
36
|
+
*
|
|
37
|
+
* Note: Typically does not need to be called directly by client extensions
|
|
38
|
+
* unless implementing a custom experience.
|
|
39
|
+
*/
|
|
40
|
+
function getJobBasedDescription(data) {
|
|
41
|
+
if (data.conclusion !== null) {
|
|
42
|
+
const conclusion = convertConclusionToVerb((0, vscode_azext_utils_1.nonNullProp)(data, 'conclusion'));
|
|
43
|
+
const completedAt = dayjs(data.completed_at).fromNow();
|
|
44
|
+
return `${conclusion} ${completedAt}`;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const status = convertStatusToVerb((0, vscode_azext_utils_1.nonNullProp)(data, 'status'));
|
|
48
|
+
const startedAt = !data.started_at ? vscode_1.l10n.t('now') : dayjs(data.started_at).fromNow();
|
|
49
|
+
return `${status} ${startedAt}`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.getJobBasedDescription = getJobBasedDescription;
|
|
53
|
+
/**
|
|
54
|
+
* Select an icon based on its Action-related status.
|
|
55
|
+
*
|
|
56
|
+
* Note: Typically does not need to be called directly by client extensions
|
|
57
|
+
* unless implementing a custom experience.
|
|
58
|
+
*/
|
|
59
|
+
function getActionBasedIconPath(data) {
|
|
60
|
+
let id;
|
|
61
|
+
let colorId;
|
|
62
|
+
if (data.conclusion !== null) {
|
|
63
|
+
switch ((0, vscode_azext_utils_1.nonNullProp)(data, 'conclusion')) {
|
|
64
|
+
case Conclusion.Cancelled:
|
|
65
|
+
id = 'circle-slash';
|
|
66
|
+
colorId = 'testing.iconUnset';
|
|
67
|
+
break;
|
|
68
|
+
case Conclusion.Failure:
|
|
69
|
+
id = 'error';
|
|
70
|
+
colorId = 'testing.iconFailed';
|
|
71
|
+
break;
|
|
72
|
+
case Conclusion.Skipped:
|
|
73
|
+
id = 'debug-step-over';
|
|
74
|
+
colorId = 'testing.iconSkipped';
|
|
75
|
+
break;
|
|
76
|
+
case Conclusion.Success:
|
|
77
|
+
id = 'pass';
|
|
78
|
+
colorId = 'testing.iconPassed';
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
switch ((0, vscode_azext_utils_1.nonNullProp)(data, 'status')) {
|
|
84
|
+
case Status.Queued:
|
|
85
|
+
id = 'clock';
|
|
86
|
+
colorId = 'testing.iconQueued';
|
|
87
|
+
break;
|
|
88
|
+
case Status.InProgress:
|
|
89
|
+
id = 'play-circle';
|
|
90
|
+
colorId = 'testing.iconUnset';
|
|
91
|
+
break;
|
|
92
|
+
case Status.Completed:
|
|
93
|
+
id = 'pass';
|
|
94
|
+
colorId = 'testing.iconPassed';
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return new vscode_1.ThemeIcon(id, colorId ? new vscode_1.ThemeColor(colorId) : undefined);
|
|
99
|
+
}
|
|
100
|
+
exports.getActionBasedIconPath = getActionBasedIconPath;
|
|
101
|
+
// Helpers...
|
|
102
|
+
function convertConclusionToVerb(conclusion) {
|
|
103
|
+
switch (conclusion) {
|
|
104
|
+
case Conclusion.Success:
|
|
105
|
+
return vscode_1.l10n.t('succeeded');
|
|
106
|
+
case Conclusion.Cancelled:
|
|
107
|
+
return vscode_1.l10n.t('cancelled');
|
|
108
|
+
case Conclusion.Failure:
|
|
109
|
+
return vscode_1.l10n.t('failed');
|
|
110
|
+
case Conclusion.Skipped:
|
|
111
|
+
return vscode_1.l10n.t('skipped');
|
|
112
|
+
default:
|
|
113
|
+
return '';
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function convertStatusToVerb(status) {
|
|
117
|
+
switch (status) {
|
|
118
|
+
case Status.InProgress:
|
|
119
|
+
return vscode_1.l10n.t('started');
|
|
120
|
+
case Status.Queued:
|
|
121
|
+
return vscode_1.l10n.t('queued');
|
|
122
|
+
case Status.Completed:
|
|
123
|
+
return vscode_1.l10n.t('completed');
|
|
124
|
+
default:
|
|
125
|
+
return '';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=actionUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getGitHubAccessToken(): Promise<string>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.getGitHubAccessToken = void 0;
|
|
17
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
18
|
+
const vscode_1 = require("vscode");
|
|
19
|
+
const constants_1 = require("../constants");
|
|
20
|
+
function getGitHubAccessToken() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
try {
|
|
23
|
+
const token = (yield vscode_1.authentication.getSession(constants_1.gitHubAuthProviderId, constants_1.gitHubScopes, { createIfNone: true })).accessToken;
|
|
24
|
+
// Workaround for VS Code returning a different token when connected to a CodeSpace in a browser
|
|
25
|
+
// see https://github.com/microsoft/vscode-azurestaticwebapps/issues/827#issuecomment-1597881084 for details
|
|
26
|
+
if (token.startsWith('ghu_')) {
|
|
27
|
+
// Request a fake scope to force VS Code to give us a token of the right type
|
|
28
|
+
return (yield vscode_1.authentication.getSession(constants_1.gitHubAuthProviderId, [...constants_1.gitHubScopes, 'x-AzToolsScope'], { createIfNone: true })).accessToken;
|
|
29
|
+
}
|
|
30
|
+
return token;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if ((0, vscode_azext_utils_1.parseError)(error).message === 'User did not consent to login.') {
|
|
34
|
+
throw new vscode_azext_utils_1.UserCancelledError('getGitHubToken');
|
|
35
|
+
}
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.getGitHubAccessToken = getGitHubAccessToken;
|
|
41
|
+
//# sourceMappingURL=getGitHubAccessToken.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface ParsedGitHubUrl {
|
|
2
|
+
/**
|
|
3
|
+
* The original URL for reference
|
|
4
|
+
* @example 'https://github.com/microsoft/foo-bar'
|
|
5
|
+
*/
|
|
6
|
+
urlReference?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The owner or organization, parsed from the full GitHub URL
|
|
9
|
+
* @example 'microsoft'
|
|
10
|
+
*/
|
|
11
|
+
ownerOrOrganization?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The repository (base), parsed from the full GitHub URL
|
|
14
|
+
* @example 'foo-bar'
|
|
15
|
+
*/
|
|
16
|
+
repositoryName?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A minimal utility function for parsing a full GitHub URL into its constituent parts
|
|
20
|
+
* @params url A complete GitHub repository URL
|
|
21
|
+
* @example 'https://github.com/microsoft/foo-bar'
|
|
22
|
+
*/
|
|
23
|
+
export declare function gitHubUrlParse(url: string): ParsedGitHubUrl;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.gitHubUrlParse = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* A minimal utility function for parsing a full GitHub URL into its constituent parts
|
|
10
|
+
* @params url A complete GitHub repository URL
|
|
11
|
+
* @example 'https://github.com/microsoft/foo-bar'
|
|
12
|
+
*/
|
|
13
|
+
function gitHubUrlParse(url) {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const match = url.match(/github\.com\/(?<ownerOrOrganization>[^/]+)\/(?<repositoryName>[^/]+)/i);
|
|
16
|
+
return {
|
|
17
|
+
urlReference: url,
|
|
18
|
+
ownerOrOrganization: (_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.ownerOrOrganization,
|
|
19
|
+
repositoryName: (_b = match === null || match === void 0 ? void 0 : match.groups) === null || _b === void 0 ? void 0 : _b.repositoryName
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.gitHubUrlParse = gitHubUrlParse;
|
|
23
|
+
//# sourceMappingURL=gitHubUrlParse.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AzureWizardPromptStep } from "@microsoft/vscode-azext-utils";
|
|
2
|
+
import type { GitHubContext } from "../GitHubContext";
|
|
3
|
+
/**
|
|
4
|
+
* Used to prompt the user for the GitHub repository branch
|
|
5
|
+
* @prerequisites gitHubRepository, gitHubRepositoryOwner
|
|
6
|
+
* @populates gitHubBranch
|
|
7
|
+
*/
|
|
8
|
+
export declare class GitHubBranchListStep extends AzureWizardPromptStep<GitHubContext> {
|
|
9
|
+
private picks;
|
|
10
|
+
prompt(context: GitHubContext): Promise<void>;
|
|
11
|
+
shouldPrompt(context: GitHubContext): boolean;
|
|
12
|
+
private getPicks;
|
|
13
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.GitHubBranchListStep = void 0;
|
|
17
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
18
|
+
const vscode_1 = require("vscode");
|
|
19
|
+
const constants_1 = require("../constants");
|
|
20
|
+
const getBranches_1 = require("../wrappers/getBranches");
|
|
21
|
+
/**
|
|
22
|
+
* Used to prompt the user for the GitHub repository branch
|
|
23
|
+
* @prerequisites gitHubRepository, gitHubRepositoryOwner
|
|
24
|
+
* @populates gitHubBranch
|
|
25
|
+
*/
|
|
26
|
+
class GitHubBranchListStep extends vscode_azext_utils_1.AzureWizardPromptStep {
|
|
27
|
+
prompt(context) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
// We always want fresh picks before prompting in case the user has pressed the back button
|
|
30
|
+
this.picks = [];
|
|
31
|
+
const placeHolder = vscode_1.l10n.t('Select a branch');
|
|
32
|
+
let page = 0;
|
|
33
|
+
while (!context.gitHubBranch) {
|
|
34
|
+
page++;
|
|
35
|
+
context.gitHubBranch = (yield context.ui.showQuickPick(this.getPicks(context, page), { placeHolder })).data;
|
|
36
|
+
}
|
|
37
|
+
context.valuesToMask.push(context.gitHubBranch);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
shouldPrompt(context) {
|
|
41
|
+
return !context.gitHubBranch;
|
|
42
|
+
}
|
|
43
|
+
getPicks(context, page) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const perPage = 50;
|
|
46
|
+
const branchParams = {
|
|
47
|
+
owner: (0, vscode_azext_utils_1.nonNullProp)(context, 'gitHubRepositoryOwner'),
|
|
48
|
+
repo: (0, vscode_azext_utils_1.nonNullProp)(context, 'gitHubRepository'),
|
|
49
|
+
per_page: perPage,
|
|
50
|
+
page
|
|
51
|
+
};
|
|
52
|
+
const branches = yield (0, getBranches_1.getBranches)(context, branchParams);
|
|
53
|
+
this.picks.push(...branches.map((branch) => { return { label: branch.name, data: branch.name }; }));
|
|
54
|
+
this.picks.sort((a, b) => {
|
|
55
|
+
if (a.label === 'main' || a.label === 'master') {
|
|
56
|
+
return -1;
|
|
57
|
+
}
|
|
58
|
+
else if (b.label === 'main' || b.label === 'master') {
|
|
59
|
+
return 1;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return a.label.localeCompare(b.label);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
const maxAvailablePicks = perPage * page;
|
|
66
|
+
return maxAvailablePicks === this.picks.length ? [...this.picks, constants_1.loadMoreQp] : this.picks;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.GitHubBranchListStep = GitHubBranchListStep;
|
|
71
|
+
//# sourceMappingURL=GitHubBranchListStep.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AzureWizardPromptStep } from "@microsoft/vscode-azext-utils";
|
|
2
|
+
import type { GitHubContext } from "../GitHubContext";
|
|
3
|
+
/**
|
|
4
|
+
* Used to prompt the user for the repository's GitHub organization
|
|
5
|
+
* @populates gitHubOrg
|
|
6
|
+
*/
|
|
7
|
+
export declare class GitHubOrgListStep extends AzureWizardPromptStep<GitHubContext> {
|
|
8
|
+
prompt(context: GitHubContext): Promise<void>;
|
|
9
|
+
shouldPrompt(context: GitHubContext): boolean;
|
|
10
|
+
private getPicks;
|
|
11
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.GitHubOrgListStep = void 0;
|
|
17
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
18
|
+
const vscode_1 = require("vscode");
|
|
19
|
+
const getAuthenticatedUser_1 = require("../wrappers/getAuthenticatedUser");
|
|
20
|
+
const getOrgs_1 = require("../wrappers/getOrgs");
|
|
21
|
+
/**
|
|
22
|
+
* Used to prompt the user for the repository's GitHub organization
|
|
23
|
+
* @populates gitHubOrg
|
|
24
|
+
*/
|
|
25
|
+
class GitHubOrgListStep extends vscode_azext_utils_1.AzureWizardPromptStep {
|
|
26
|
+
prompt(context) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const placeHolder = vscode_1.l10n.t('Select an organization');
|
|
29
|
+
context.gitHubOrg = (yield context.ui.showQuickPick(this.getPicks(context), { placeHolder })).data;
|
|
30
|
+
if (context.gitHubOrg) {
|
|
31
|
+
context.valuesToMask.push(context.gitHubOrg);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
shouldPrompt(context) {
|
|
36
|
+
return !context.gitHubOrg;
|
|
37
|
+
}
|
|
38
|
+
getPicks(context) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const user = yield (0, getAuthenticatedUser_1.getAuthenticatedUser)(context);
|
|
41
|
+
const orgs = yield (0, getOrgs_1.getOrgs)(context);
|
|
42
|
+
return [
|
|
43
|
+
{ label: user.login, data: undefined },
|
|
44
|
+
...orgs.map((org) => {
|
|
45
|
+
return { label: org.login, data: org.login };
|
|
46
|
+
})
|
|
47
|
+
];
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.GitHubOrgListStep = GitHubOrgListStep;
|
|
52
|
+
//# sourceMappingURL=GitHubOrgListStep.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AzureWizardPromptStep } from "@microsoft/vscode-azext-utils";
|
|
2
|
+
import type { GitHubContext } from "../GitHubContext";
|
|
3
|
+
/**
|
|
4
|
+
* Used to prompt the user for the GitHub repository
|
|
5
|
+
* @prerequisites gitHubOrg
|
|
6
|
+
* @populates gitHubRepository, gitHubRepositoryOwner, gitHubRepositoryUrl
|
|
7
|
+
*/
|
|
8
|
+
export declare class GitHubRepositoryListStep extends AzureWizardPromptStep<GitHubContext> {
|
|
9
|
+
private picks;
|
|
10
|
+
prompt(context: GitHubContext): Promise<void>;
|
|
11
|
+
shouldPrompt(context: GitHubContext): boolean;
|
|
12
|
+
private getPicks;
|
|
13
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.GitHubRepositoryListStep = void 0;
|
|
17
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
18
|
+
const vscode_1 = require("vscode");
|
|
19
|
+
const constants_1 = require("../constants");
|
|
20
|
+
const getRepositories_1 = require("../wrappers/getRepositories");
|
|
21
|
+
/**
|
|
22
|
+
* Used to prompt the user for the GitHub repository
|
|
23
|
+
* @prerequisites gitHubOrg
|
|
24
|
+
* @populates gitHubRepository, gitHubRepositoryOwner, gitHubRepositoryUrl
|
|
25
|
+
*/
|
|
26
|
+
class GitHubRepositoryListStep extends vscode_azext_utils_1.AzureWizardPromptStep {
|
|
27
|
+
prompt(context) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
// We always want fresh picks before prompting in case the user has pressed the back button
|
|
30
|
+
this.picks = [];
|
|
31
|
+
const placeHolder = vscode_1.l10n.t('Select a repository');
|
|
32
|
+
let page = 0;
|
|
33
|
+
let repositoryData;
|
|
34
|
+
while (!repositoryData) {
|
|
35
|
+
page++;
|
|
36
|
+
repositoryData = (yield context.ui.showQuickPick(this.getPicks(context, page), { placeHolder })).data;
|
|
37
|
+
}
|
|
38
|
+
context.gitHubRepository = repositoryData.repo;
|
|
39
|
+
context.gitHubRepositoryOwner = repositoryData.owner;
|
|
40
|
+
context.gitHubRepositoryUrl = repositoryData.url;
|
|
41
|
+
context.valuesToMask.push(context.gitHubRepository);
|
|
42
|
+
context.valuesToMask.push(context.gitHubRepositoryOwner);
|
|
43
|
+
context.valuesToMask.push(context.gitHubRepositoryUrl);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
shouldPrompt(context) {
|
|
47
|
+
return !context.gitHubRepository || !context.gitHubRepositoryOwner;
|
|
48
|
+
}
|
|
49
|
+
getPicks(context, page) {
|
|
50
|
+
var _a;
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const perPage = 50;
|
|
53
|
+
const userRepoParams = {
|
|
54
|
+
affiliation: 'owner',
|
|
55
|
+
visibility: 'all',
|
|
56
|
+
per_page: perPage,
|
|
57
|
+
page
|
|
58
|
+
};
|
|
59
|
+
const orgRepoParams = {
|
|
60
|
+
// Doesn't matter if context.gitHubOrg is undefined; that just means we will end up calling 'getRepositoriesByUser' instead
|
|
61
|
+
org: (_a = context.gitHubOrg) !== null && _a !== void 0 ? _a : '',
|
|
62
|
+
type: 'all',
|
|
63
|
+
per_page: perPage,
|
|
64
|
+
page
|
|
65
|
+
};
|
|
66
|
+
// Intentionally use the same map callback on two lines below to force TypeScript to infer the proper repo type
|
|
67
|
+
this.picks.push(...(context.gitHubOrg ?
|
|
68
|
+
(yield (0, getRepositories_1.getRepositoriesByOrg)(context, orgRepoParams)).map((repo) => { return { label: repo.name, data: { owner: repo.owner.login, repo: repo.name, url: repo.html_url } }; }) :
|
|
69
|
+
(yield (0, getRepositories_1.getRepositoriesByUser)(context, userRepoParams)).map((repo) => { return { label: repo.name, data: { owner: repo.owner.login, repo: repo.name, url: repo.html_url } }; })));
|
|
70
|
+
this.picks.sort((a, b) => a.label.localeCompare(b.label));
|
|
71
|
+
const maxPicksAvailable = perPage * page;
|
|
72
|
+
return (maxPicksAvailable === this.picks.length) ? [...this.picks, constants_1.loadMoreQp] : this.picks;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.GitHubRepositoryListStep = GitHubRepositoryListStep;
|
|
77
|
+
//# sourceMappingURL=GitHubRepositoryListStep.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RestEndpointMethodTypes } from "@octokit/rest";
|
|
2
|
+
import type { GitHubContext } from "../GitHubContext";
|
|
3
|
+
export type ActionsListWorkflowRuns = RestEndpointMethodTypes["actions"]["listWorkflowRunsForRepo"]["response"]["data"];
|
|
4
|
+
export type ActionWorkflowRuns = ActionsListWorkflowRuns["workflow_runs"][number];
|
|
5
|
+
export type GetActionsListWorkflowRunsParams = RestEndpointMethodTypes["actions"]["listWorkflowRunsForRepo"]["parameters"];
|
|
6
|
+
/**
|
|
7
|
+
* A wrapper for Octokit's: `client.actions.listWorkflowRunsForRepo`
|
|
8
|
+
*/
|
|
9
|
+
export declare function getActions(context: GitHubContext, params?: GetActionsListWorkflowRunsParams): Promise<ActionsListWorkflowRuns>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.getActions = void 0;
|
|
17
|
+
const createOctokitClient_1 = require("../createOctokitClient");
|
|
18
|
+
/**
|
|
19
|
+
* A wrapper for Octokit's: `client.actions.listWorkflowRunsForRepo`
|
|
20
|
+
*/
|
|
21
|
+
function getActions(context, params) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const client = yield (0, createOctokitClient_1.createOctokitClient)(context);
|
|
24
|
+
return (yield client.actions.listWorkflowRunsForRepo(params)).data;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.getActions = getActions;
|
|
28
|
+
//# sourceMappingURL=getActions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RestEndpointMethodTypes } from "@octokit/rest";
|
|
2
|
+
import type { GitHubContext } from "../GitHubContext";
|
|
3
|
+
export type AuthenticatedUser = RestEndpointMethodTypes["users"]["getAuthenticated"]["response"]["data"];
|
|
4
|
+
/**
|
|
5
|
+
* A wrapper for Octokit's: `client.users.getAuthenticated`
|
|
6
|
+
*/
|
|
7
|
+
export declare function getAuthenticatedUser(context: GitHubContext): Promise<AuthenticatedUser>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.getAuthenticatedUser = void 0;
|
|
17
|
+
const createOctokitClient_1 = require("../createOctokitClient");
|
|
18
|
+
/**
|
|
19
|
+
* A wrapper for Octokit's: `client.users.getAuthenticated`
|
|
20
|
+
*/
|
|
21
|
+
function getAuthenticatedUser(context) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const client = yield (0, createOctokitClient_1.createOctokitClient)(context);
|
|
24
|
+
return (yield client.users.getAuthenticated()).data;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.getAuthenticatedUser = getAuthenticatedUser;
|
|
28
|
+
//# sourceMappingURL=getAuthenticatedUser.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RestEndpointMethodTypes } from "@octokit/rest";
|
|
2
|
+
import type { GitHubContext } from "../GitHubContext";
|
|
3
|
+
export type Branches = RestEndpointMethodTypes["repos"]["listBranches"]["response"]["data"];
|
|
4
|
+
export type GetBranchesParams = RestEndpointMethodTypes["repos"]["listBranches"]["parameters"] & {
|
|
5
|
+
owner: string;
|
|
6
|
+
repo: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A wrapper for Octokit's: `client.repos.listBranches`
|
|
10
|
+
*/
|
|
11
|
+
export declare function getBranches(context: GitHubContext, reqParams: GetBranchesParams): Promise<Branches>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.getBranches = void 0;
|
|
17
|
+
const createOctokitClient_1 = require("../createOctokitClient");
|
|
18
|
+
/**
|
|
19
|
+
* A wrapper for Octokit's: `client.repos.listBranches`
|
|
20
|
+
*/
|
|
21
|
+
function getBranches(context, reqParams) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const client = yield (0, createOctokitClient_1.createOctokitClient)(context);
|
|
24
|
+
return (yield client.repos.listBranches(reqParams)).data;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.getBranches = getBranches;
|
|
28
|
+
//# sourceMappingURL=getBranches.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RestEndpointMethodTypes } from "@octokit/rest";
|
|
2
|
+
import type { GitHubContext } from "../GitHubContext";
|
|
3
|
+
export type Jobs = RestEndpointMethodTypes["actions"]["listJobsForWorkflowRun"]["response"]["data"];
|
|
4
|
+
export type Job = Jobs["jobs"][number];
|
|
5
|
+
export type JobStep = NonNullable<Job["steps"]>[number];
|
|
6
|
+
export type GetJobsParams = RestEndpointMethodTypes["actions"]["listJobsForWorkflowRun"]["parameters"];
|
|
7
|
+
/**
|
|
8
|
+
* A wrapper for Octokit's: `client.actions.listJobsForWorkflowRun`
|
|
9
|
+
*/
|
|
10
|
+
export declare function getJobs(context: GitHubContext, params: GetJobsParams): Promise<Jobs>;
|