@microsoft/vscode-azext-github 1.0.7 → 2.0.1
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/dist/cjs/src/createOctokitClient.js +24 -0
- package/dist/cjs/src/extensionVariables.js +16 -0
- package/{out → dist/cjs}/src/index.js +3 -1
- package/dist/cjs/src/tree/ActionItem.js +79 -0
- package/dist/cjs/src/tree/ActionsItemBase.js +104 -0
- package/{out → dist/cjs}/src/tree/JobItem.js +15 -18
- package/{out → dist/cjs}/src/tree/StepItem.js +13 -4
- package/{out → dist/cjs}/src/utils/actionUtils.js +11 -9
- package/dist/cjs/src/utils/getGitHubAccessToken.js +30 -0
- package/{out → dist/cjs}/src/utils/gitHubUrlParse.js +4 -5
- package/dist/cjs/src/wizard/GitHubBranchListStep.js +60 -0
- package/dist/cjs/src/wizard/GitHubOrgListStep.js +39 -0
- package/dist/cjs/src/wizard/GitHubRepositoryListStep.js +66 -0
- package/dist/cjs/src/wrappers/getActions.js +16 -0
- package/dist/cjs/src/wrappers/getAuthenticatedUser.js +16 -0
- package/dist/cjs/src/wrappers/getBranches.js +16 -0
- package/dist/cjs/src/wrappers/getJobs.js +16 -0
- package/dist/cjs/src/wrappers/getOrgs.js +16 -0
- package/dist/cjs/src/wrappers/getRepositories.js +24 -0
- package/dist/esm/src/GitHubContext.js +6 -0
- package/dist/esm/src/constants.js +10 -0
- package/{out → dist/esm}/src/createOctokitClient.d.ts +1 -1
- package/dist/esm/src/createOctokitClient.js +21 -0
- package/dist/esm/src/extensionVariables.d.ts +6 -0
- package/dist/esm/src/extensionVariables.js +13 -0
- package/{out → dist/esm}/src/index.d.ts +1 -1
- package/dist/esm/src/index.js +23 -0
- package/{out → dist/esm}/src/tree/ActionItem.d.ts +6 -6
- package/dist/esm/src/tree/ActionItem.js +75 -0
- package/{out → dist/esm}/src/tree/ActionsItemBase.d.ts +3 -3
- package/dist/esm/src/tree/ActionsItemBase.js +100 -0
- package/{out → dist/esm}/src/tree/JobItem.d.ts +6 -6
- package/dist/esm/src/tree/JobItem.js +44 -0
- package/{out → dist/esm}/src/tree/StepItem.d.ts +6 -6
- package/dist/esm/src/tree/StepItem.js +38 -0
- package/dist/esm/src/utils/actionUtils.js +122 -0
- package/dist/esm/src/utils/getGitHubAccessToken.js +27 -0
- package/dist/esm/src/utils/gitHubUrlParse.js +19 -0
- package/dist/esm/src/wizard/GitHubBranchListStep.js +56 -0
- package/dist/esm/src/wizard/GitHubOrgListStep.js +35 -0
- package/dist/esm/src/wizard/GitHubRepositoryListStep.js +62 -0
- package/dist/esm/src/wrappers/getActions.js +13 -0
- package/dist/esm/src/wrappers/getAuthenticatedUser.js +13 -0
- package/dist/esm/src/wrappers/getBranches.js +13 -0
- package/dist/esm/src/wrappers/getJobs.js +13 -0
- package/dist/esm/src/wrappers/getOrgs.js +13 -0
- package/dist/esm/src/wrappers/getRepositories.js +20 -0
- package/package.json +18 -24
- package/out/src/createOctokitClient.js +0 -36
- package/out/src/extensionVariables.d.ts +0 -13
- package/out/src/extensionVariables.js +0 -43
- package/out/src/tree/ActionItem.js +0 -81
- package/out/src/tree/ActionsItemBase.js +0 -114
- package/out/src/utils/getGitHubAccessToken.js +0 -42
- package/out/src/wizard/GitHubBranchListStep.js +0 -71
- package/out/src/wizard/GitHubOrgListStep.js +0 -52
- package/out/src/wizard/GitHubRepositoryListStep.js +0 -77
- package/out/src/wrappers/getActions.js +0 -28
- package/out/src/wrappers/getAuthenticatedUser.js +0 -28
- package/out/src/wrappers/getBranches.js +0 -28
- package/out/src/wrappers/getJobs.js +0 -28
- package/out/src/wrappers/getOrgs.js +0 -28
- package/out/src/wrappers/getRepositories.js +0 -38
- /package/{out → dist/cjs}/src/GitHubContext.js +0 -0
- /package/{out → dist/cjs}/src/constants.js +0 -0
- /package/{out → dist/esm}/src/GitHubContext.d.ts +0 -0
- /package/{out → dist/esm}/src/constants.d.ts +0 -0
- /package/{out → dist/esm}/src/utils/actionUtils.d.ts +0 -0
- /package/{out → dist/esm}/src/utils/getGitHubAccessToken.d.ts +0 -0
- /package/{out → dist/esm}/src/utils/gitHubUrlParse.d.ts +0 -0
- /package/{out → dist/esm}/src/wizard/GitHubBranchListStep.d.ts +0 -0
- /package/{out → dist/esm}/src/wizard/GitHubOrgListStep.d.ts +0 -0
- /package/{out → dist/esm}/src/wizard/GitHubRepositoryListStep.d.ts +0 -0
- /package/{out → dist/esm}/src/wrappers/getActions.d.ts +0 -0
- /package/{out → dist/esm}/src/wrappers/getAuthenticatedUser.d.ts +0 -0
- /package/{out → dist/esm}/src/wrappers/getBranches.d.ts +0 -0
- /package/{out → dist/esm}/src/wrappers/getJobs.d.ts +0 -0
- /package/{out → dist/esm}/src/wrappers/getOrgs.d.ts +0 -0
- /package/{out → dist/esm}/src/wrappers/getRepositories.d.ts +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
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.createOctokitClient = createOctokitClient;
|
|
8
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
9
|
+
const getGitHubAccessToken_1 = require("./utils/getGitHubAccessToken");
|
|
10
|
+
/**
|
|
11
|
+
* Can be used to initialize a new Octokit client.
|
|
12
|
+
*
|
|
13
|
+
* Note: Typically does not need to be called directly by client extensions
|
|
14
|
+
* unless implementing a custom behavior.
|
|
15
|
+
*/
|
|
16
|
+
async function createOctokitClient(context) {
|
|
17
|
+
const { Octokit } = await import('@octokit/rest');
|
|
18
|
+
context.gitHubAccessToken ||= await (0, getGitHubAccessToken_1.getGitHubAccessToken)();
|
|
19
|
+
return new Octokit({
|
|
20
|
+
userAgent: (0, vscode_azext_utils_1.appendExtensionUserAgent)(),
|
|
21
|
+
auth: context.gitHubAccessToken
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=createOctokitClient.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
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.registerGitHubExtensionVariables = registerGitHubExtensionVariables;
|
|
8
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
9
|
+
/**
|
|
10
|
+
* Call this to register common variables used throughout the github package.
|
|
11
|
+
* @deprecated This method is no longer necessary and will be removed in a future release. You can safely remove any calls to this method.
|
|
12
|
+
*/
|
|
13
|
+
function registerGitHubExtensionVariables(extVars) {
|
|
14
|
+
(0, vscode_azext_utils_1.registerUIExtensionVariables)(extVars);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=extensionVariables.js.map
|
|
@@ -18,7 +18,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
18
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
|
|
21
|
+
exports.registerGitHubExtensionVariables = void 0;
|
|
22
|
+
var extensionVariables_1 = require("./extensionVariables");
|
|
23
|
+
Object.defineProperty(exports, "registerGitHubExtensionVariables", { enumerable: true, get: function () { return extensionVariables_1.registerGitHubExtensionVariables; } });
|
|
22
24
|
__exportStar(require("./GitHubContext"), exports);
|
|
23
25
|
__exportStar(require("./createOctokitClient"), exports);
|
|
24
26
|
__exportStar(require("./utils/getGitHubAccessToken"), exports);
|
|
@@ -0,0 +1,79 @@
|
|
|
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.ActionItem = void 0;
|
|
8
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
9
|
+
const vscode_1 = require("vscode");
|
|
10
|
+
const actionUtils_1 = require("../utils/actionUtils");
|
|
11
|
+
const gitHubUrlParse_1 = require("../utils/gitHubUrlParse");
|
|
12
|
+
const getJobs_1 = require("../wrappers/getJobs");
|
|
13
|
+
const JobItem_1 = require("./JobItem");
|
|
14
|
+
class ActionItem {
|
|
15
|
+
parentResourceId;
|
|
16
|
+
extensionPrefixContextValue;
|
|
17
|
+
actionWorkflowRuns;
|
|
18
|
+
static contextValueSuffix = 'ActionItem';
|
|
19
|
+
static completedContextValue = 'actionState:completed';
|
|
20
|
+
static inProgressContextValue = 'actionState:inProgress';
|
|
21
|
+
constructor(parentResourceId, extensionPrefixContextValue, actionWorkflowRuns) {
|
|
22
|
+
this.parentResourceId = parentResourceId;
|
|
23
|
+
this.extensionPrefixContextValue = extensionPrefixContextValue;
|
|
24
|
+
this.actionWorkflowRuns = actionWorkflowRuns;
|
|
25
|
+
}
|
|
26
|
+
get id() {
|
|
27
|
+
return `${this.parentResourceId}/${this.actionWorkflowRuns.id}`;
|
|
28
|
+
}
|
|
29
|
+
get label() {
|
|
30
|
+
return this.actionWorkflowRuns.head_commit?.message || this.actionWorkflowRuns.head_sha;
|
|
31
|
+
}
|
|
32
|
+
get viewProperties() {
|
|
33
|
+
return {
|
|
34
|
+
data: this.actionWorkflowRuns,
|
|
35
|
+
label: this.label,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
get contextValue() {
|
|
39
|
+
const actionTreeItemContextValue = `${this.extensionPrefixContextValue}${ActionItem.contextValueSuffix}`;
|
|
40
|
+
const values = [actionTreeItemContextValue];
|
|
41
|
+
if ((0, vscode_azext_utils_1.nonNullProp)(this.actionWorkflowRuns, 'status') === actionUtils_1.Status.Completed) {
|
|
42
|
+
values.push(ActionItem.completedContextValue);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
values.push(ActionItem.inProgressContextValue);
|
|
46
|
+
}
|
|
47
|
+
return (0, vscode_azext_utils_1.createContextValue)(values);
|
|
48
|
+
}
|
|
49
|
+
getTreeItem() {
|
|
50
|
+
return {
|
|
51
|
+
id: this.id,
|
|
52
|
+
label: this.label,
|
|
53
|
+
description: this.actionWorkflowRuns.event,
|
|
54
|
+
iconPath: (0, actionUtils_1.getActionBasedIconPath)(this.actionWorkflowRuns),
|
|
55
|
+
contextValue: this.contextValue,
|
|
56
|
+
collapsibleState: vscode_1.TreeItemCollapsibleState.Collapsed
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async getChildren() {
|
|
60
|
+
const jobsData = await (0, vscode_azext_utils_1.callWithTelemetryAndErrorHandling)('getActionChildren', async (context) => {
|
|
61
|
+
const { ownerOrOrganization, repositoryName } = (0, gitHubUrlParse_1.gitHubUrlParse)(this.actionWorkflowRuns.repository.html_url);
|
|
62
|
+
const getJobsParams = {
|
|
63
|
+
owner: (0, vscode_azext_utils_1.nonNullValue)(ownerOrOrganization),
|
|
64
|
+
repo: (0, vscode_azext_utils_1.nonNullValue)(repositoryName),
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
66
|
+
run_id: this.actionWorkflowRuns.id
|
|
67
|
+
};
|
|
68
|
+
return await (0, getJobs_1.getJobs)(context, getJobsParams);
|
|
69
|
+
});
|
|
70
|
+
if (jobsData?.total_count) {
|
|
71
|
+
return jobsData.jobs.map((job) => new JobItem_1.JobItem(this.id, this.extensionPrefixContextValue, job));
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.ActionItem = ActionItem;
|
|
79
|
+
//# sourceMappingURL=ActionItem.js.map
|
|
@@ -0,0 +1,104 @@
|
|
|
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.ActionsItemBase = void 0;
|
|
8
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
9
|
+
const vscode_1 = require("vscode");
|
|
10
|
+
const gitHubUrlParse_1 = require("../utils/gitHubUrlParse");
|
|
11
|
+
const getActions_1 = require("../wrappers/getActions");
|
|
12
|
+
const ActionItem_1 = require("./ActionItem");
|
|
13
|
+
/**
|
|
14
|
+
* Base tree node for setting up and tracking GitHub Actions in the tree view.
|
|
15
|
+
* Branching children will be automatically setup and included to track actions, jobs, and steps.
|
|
16
|
+
*/
|
|
17
|
+
class ActionsItemBase {
|
|
18
|
+
parentId;
|
|
19
|
+
contextValueExtensionPrefix;
|
|
20
|
+
static contextValueSuffix = 'ActionsItem';
|
|
21
|
+
static connectedContextValue = 'actionsConnected:true';
|
|
22
|
+
static unconnectedContextValue = 'actionsConnected:false';
|
|
23
|
+
static idSuffix = 'actions';
|
|
24
|
+
/**
|
|
25
|
+
* @param parentId A unique identifier corresponding to the id of the parent tree node
|
|
26
|
+
* @param contextValueExtensionPrefix The extension prefix used in constructing context values for the 'ActionsItem'
|
|
27
|
+
* and its children. Passing 'containerApps' becomes `containerApps${ActionsItemBase.contextValueSuffix}`.
|
|
28
|
+
*/
|
|
29
|
+
constructor(parentId, contextValueExtensionPrefix) {
|
|
30
|
+
this.parentId = parentId;
|
|
31
|
+
this.contextValueExtensionPrefix = contextValueExtensionPrefix;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Constructed using the format: `${this.parentId}/${ActionsTreeItemBase.idSuffix}`
|
|
35
|
+
*/
|
|
36
|
+
get id() {
|
|
37
|
+
return `${this.parentId}/${ActionsItemBase.idSuffix}`;
|
|
38
|
+
}
|
|
39
|
+
label = 'Actions';
|
|
40
|
+
getContextValue(isConnected) {
|
|
41
|
+
const actionsTreeItemContextValue = `${this.contextValueExtensionPrefix}${ActionsItemBase.contextValueSuffix}`;
|
|
42
|
+
const values = [actionsTreeItemContextValue];
|
|
43
|
+
values.push(isConnected ? ActionsItemBase.connectedContextValue : ActionsItemBase.unconnectedContextValue);
|
|
44
|
+
return (0, vscode_azext_utils_1.createContextValue)(values);
|
|
45
|
+
}
|
|
46
|
+
async getTreeItem() {
|
|
47
|
+
const isConnected = !!await this.getSourceControl();
|
|
48
|
+
return {
|
|
49
|
+
id: this.id,
|
|
50
|
+
label: this.label,
|
|
51
|
+
description: isConnected ? vscode_1.l10n.t('Connected') : '',
|
|
52
|
+
iconPath: new vscode_1.ThemeIcon('github-inverted'),
|
|
53
|
+
contextValue: this.getContextValue(isConnected),
|
|
54
|
+
collapsibleState: vscode_1.TreeItemCollapsibleState.Collapsed,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
async getChildren() {
|
|
58
|
+
const sourceControl = await this.getSourceControl();
|
|
59
|
+
const actionsListWorkflowRuns = await (0, vscode_azext_utils_1.callWithTelemetryAndErrorHandling)('getActionsChildren', async (context) => {
|
|
60
|
+
if (!sourceControl) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
const { ownerOrOrganization, repositoryName } = (0, gitHubUrlParse_1.gitHubUrlParse)(sourceControl.repoUrl);
|
|
64
|
+
const actionWorkflowRunsParams = {
|
|
65
|
+
owner: (0, vscode_azext_utils_1.nonNullValue)(ownerOrOrganization),
|
|
66
|
+
repo: (0, vscode_azext_utils_1.nonNullValue)(repositoryName),
|
|
67
|
+
branch: sourceControl.repoBranch ?? 'main',
|
|
68
|
+
page: 1,
|
|
69
|
+
};
|
|
70
|
+
context.errorHandling.suppressDisplay = true;
|
|
71
|
+
return await (0, getActions_1.getActions)(context, actionWorkflowRunsParams);
|
|
72
|
+
});
|
|
73
|
+
if (actionsListWorkflowRuns?.total_count) {
|
|
74
|
+
return actionsListWorkflowRuns.workflow_runs.map((awr) => new ActionItem_1.ActionItem(this.id, this.contextValueExtensionPrefix, awr));
|
|
75
|
+
}
|
|
76
|
+
else if (sourceControl) {
|
|
77
|
+
// If we are able to detect a connection but fail to retrieve a list of actions
|
|
78
|
+
return [
|
|
79
|
+
(0, vscode_azext_utils_1.createGenericElement)({
|
|
80
|
+
contextValue: 'noActionsDetected',
|
|
81
|
+
id: `${this.parentId}/noActionsDetected`,
|
|
82
|
+
label: vscode_1.l10n.t('No actions detected'),
|
|
83
|
+
})
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
let command;
|
|
88
|
+
if (this.getConnectToGitHubCommand) {
|
|
89
|
+
command = await this.getConnectToGitHubCommand();
|
|
90
|
+
}
|
|
91
|
+
return [
|
|
92
|
+
(0, vscode_azext_utils_1.createGenericElement)({
|
|
93
|
+
contextValue: 'connectToGitHub',
|
|
94
|
+
id: `${this.parentId}/connectToGitHub`,
|
|
95
|
+
label: vscode_1.l10n.t('Connect to a GitHub Repository...'),
|
|
96
|
+
commandId: command?.commandId,
|
|
97
|
+
commandArgs: command?.commandArgs
|
|
98
|
+
})
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.ActionsItemBase = ActionsItemBase;
|
|
104
|
+
//# sourceMappingURL=ActionsItemBase.js.map
|
|
@@ -3,28 +3,29 @@
|
|
|
3
3
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
4
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
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
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
7
|
exports.JobItem = void 0;
|
|
17
8
|
const vscode_1 = require("vscode");
|
|
18
9
|
const actionUtils_1 = require("../utils/actionUtils");
|
|
19
10
|
const StepItem_1 = require("./StepItem");
|
|
20
11
|
class JobItem {
|
|
12
|
+
parentResourceId;
|
|
13
|
+
extensionPrefixContextValue;
|
|
14
|
+
job;
|
|
15
|
+
static contextValueSuffix = 'JobItem';
|
|
21
16
|
constructor(parentResourceId, extensionPrefixContextValue, job) {
|
|
22
17
|
this.parentResourceId = parentResourceId;
|
|
23
18
|
this.extensionPrefixContextValue = extensionPrefixContextValue;
|
|
24
19
|
this.job = job;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.
|
|
20
|
+
}
|
|
21
|
+
get id() {
|
|
22
|
+
return `${this.parentResourceId}/jobs/${this.job.id}`;
|
|
23
|
+
}
|
|
24
|
+
get label() {
|
|
25
|
+
return this.job.name || this.id;
|
|
26
|
+
}
|
|
27
|
+
get viewProperties() {
|
|
28
|
+
return {
|
|
28
29
|
data: this.job,
|
|
29
30
|
label: this.label,
|
|
30
31
|
};
|
|
@@ -39,13 +40,9 @@ class JobItem {
|
|
|
39
40
|
collapsibleState: vscode_1.TreeItemCollapsibleState.Collapsed,
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
|
-
getChildren() {
|
|
43
|
-
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
return (_b = (_a = this.job.steps) === null || _a === void 0 ? void 0 : _a.map((step) => new StepItem_1.StepItem(this.id, this.extensionPrefixContextValue, step))) !== null && _b !== void 0 ? _b : [];
|
|
46
|
-
});
|
|
43
|
+
async getChildren() {
|
|
44
|
+
return Promise.resolve(this.job.steps?.map((step) => new StepItem_1.StepItem(this.id, this.extensionPrefixContextValue, step)) ?? []);
|
|
47
45
|
}
|
|
48
46
|
}
|
|
49
47
|
exports.JobItem = JobItem;
|
|
50
|
-
JobItem.contextValueSuffix = 'JobItem';
|
|
51
48
|
//# sourceMappingURL=JobItem.js.map
|
|
@@ -7,13 +7,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.StepItem = void 0;
|
|
8
8
|
const actionUtils_1 = require("../utils/actionUtils");
|
|
9
9
|
class StepItem {
|
|
10
|
+
parentResourceId;
|
|
11
|
+
extensionPrefixContextValue;
|
|
12
|
+
step;
|
|
13
|
+
static contextValueSuffix = 'StepItem';
|
|
10
14
|
constructor(parentResourceId, extensionPrefixContextValue, step) {
|
|
11
15
|
this.parentResourceId = parentResourceId;
|
|
12
16
|
this.extensionPrefixContextValue = extensionPrefixContextValue;
|
|
13
17
|
this.step = step;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.
|
|
18
|
+
}
|
|
19
|
+
get id() {
|
|
20
|
+
return `${this.parentResourceId}/steps/${this.step.number}`;
|
|
21
|
+
}
|
|
22
|
+
get label() {
|
|
23
|
+
return this.step.name;
|
|
24
|
+
}
|
|
25
|
+
get viewProperties() {
|
|
26
|
+
return {
|
|
17
27
|
data: this.step,
|
|
18
28
|
label: this.step.name,
|
|
19
29
|
};
|
|
@@ -29,5 +39,4 @@ class StepItem {
|
|
|
29
39
|
}
|
|
30
40
|
}
|
|
31
41
|
exports.StepItem = StepItem;
|
|
32
|
-
StepItem.contextValueSuffix = 'StepItem';
|
|
33
42
|
//# sourceMappingURL=StepItem.js.map
|
|
@@ -3,14 +3,18 @@
|
|
|
3
3
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
4
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
6
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
10
|
+
exports.Status = exports.Conclusion = void 0;
|
|
11
|
+
exports.getJobBasedDescription = getJobBasedDescription;
|
|
12
|
+
exports.getActionBasedIconPath = getActionBasedIconPath;
|
|
8
13
|
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const relativeTime = require("dayjs/plugin/relativeTime");
|
|
14
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
15
|
+
const relativeTime_1 = __importDefault(require("dayjs/plugin/relativeTime"));
|
|
12
16
|
const vscode_1 = require("vscode");
|
|
13
|
-
|
|
17
|
+
dayjs_1.default.extend(relativeTime_1.default);
|
|
14
18
|
/**
|
|
15
19
|
* GitHub 'Check Run' - final conclusion of the check
|
|
16
20
|
* https://developer.github.com/v3/checks/runs/#parameters
|
|
@@ -40,16 +44,15 @@ var Status;
|
|
|
40
44
|
function getJobBasedDescription(data) {
|
|
41
45
|
if (data.conclusion !== null) {
|
|
42
46
|
const conclusion = convertConclusionToVerb((0, vscode_azext_utils_1.nonNullProp)(data, 'conclusion'));
|
|
43
|
-
const completedAt =
|
|
47
|
+
const completedAt = (0, dayjs_1.default)(data.completed_at).fromNow();
|
|
44
48
|
return `${conclusion} ${completedAt}`;
|
|
45
49
|
}
|
|
46
50
|
else {
|
|
47
51
|
const status = convertStatusToVerb((0, vscode_azext_utils_1.nonNullProp)(data, 'status'));
|
|
48
|
-
const startedAt = !data.started_at ? vscode_1.l10n.t('now') :
|
|
52
|
+
const startedAt = !data.started_at ? vscode_1.l10n.t('now') : (0, dayjs_1.default)(data.started_at).fromNow();
|
|
49
53
|
return `${status} ${startedAt}`;
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
|
-
exports.getJobBasedDescription = getJobBasedDescription;
|
|
53
56
|
/**
|
|
54
57
|
* Select an icon based on its Action-related status.
|
|
55
58
|
*
|
|
@@ -97,7 +100,6 @@ function getActionBasedIconPath(data) {
|
|
|
97
100
|
}
|
|
98
101
|
return new vscode_1.ThemeIcon(id, colorId ? new vscode_1.ThemeColor(colorId) : undefined);
|
|
99
102
|
}
|
|
100
|
-
exports.getActionBasedIconPath = getActionBasedIconPath;
|
|
101
103
|
// Helpers...
|
|
102
104
|
function convertConclusionToVerb(conclusion) {
|
|
103
105
|
switch (conclusion) {
|
|
@@ -0,0 +1,30 @@
|
|
|
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.getGitHubAccessToken = getGitHubAccessToken;
|
|
8
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
9
|
+
const vscode_1 = require("vscode");
|
|
10
|
+
const constants_1 = require("../constants");
|
|
11
|
+
async function getGitHubAccessToken() {
|
|
12
|
+
try {
|
|
13
|
+
const token = (await vscode_1.authentication.getSession(constants_1.gitHubAuthProviderId, constants_1.gitHubScopes, { createIfNone: true })).accessToken;
|
|
14
|
+
// Workaround for VS Code returning a different token when connected to a CodeSpace in a browser
|
|
15
|
+
// see https://github.com/microsoft/vscode-azurestaticwebapps/issues/827#issuecomment-1597881084 for details
|
|
16
|
+
if (token.startsWith('ghu_')) {
|
|
17
|
+
// Request a fake scope to force VS Code to give us a token of the right type
|
|
18
|
+
return (await vscode_1.authentication.getSession(constants_1.gitHubAuthProviderId, [...constants_1.gitHubScopes, 'x-AzToolsScope'], { createIfNone: true })).accessToken;
|
|
19
|
+
}
|
|
20
|
+
return token;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
// The error message is "User did not consent to login"
|
|
24
|
+
if (/did not consent/i.test((0, vscode_azext_utils_1.parseError)(error).message)) {
|
|
25
|
+
throw new vscode_azext_utils_1.UserCancelledError('getGitHubToken');
|
|
26
|
+
}
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=getGitHubAccessToken.js.map
|
|
@@ -4,20 +4,19 @@
|
|
|
4
4
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.gitHubUrlParse =
|
|
7
|
+
exports.gitHubUrlParse = gitHubUrlParse;
|
|
8
8
|
/**
|
|
9
9
|
* A minimal utility function for parsing a full GitHub URL into its constituent parts
|
|
10
10
|
* @params url A complete GitHub repository URL
|
|
11
11
|
* @example 'https://github.com/microsoft/foo-bar'
|
|
12
12
|
*/
|
|
13
13
|
function gitHubUrlParse(url) {
|
|
14
|
-
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/prefer-regexp-exec
|
|
15
15
|
const match = url.match(/github\.com\/(?<ownerOrOrganization>[^/]+)\/(?<repositoryName>[^/]+)/i);
|
|
16
16
|
return {
|
|
17
17
|
urlReference: url,
|
|
18
|
-
ownerOrOrganization:
|
|
19
|
-
repositoryName:
|
|
18
|
+
ownerOrOrganization: match?.groups?.ownerOrOrganization,
|
|
19
|
+
repositoryName: match?.groups?.repositoryName
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
exports.gitHubUrlParse = gitHubUrlParse;
|
|
23
22
|
//# sourceMappingURL=gitHubUrlParse.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
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.GitHubBranchListStep = void 0;
|
|
8
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
9
|
+
const vscode_1 = require("vscode");
|
|
10
|
+
const constants_1 = require("../constants");
|
|
11
|
+
const getBranches_1 = require("../wrappers/getBranches");
|
|
12
|
+
/**
|
|
13
|
+
* Used to prompt the user for the GitHub repository branch
|
|
14
|
+
* @prerequisites gitHubRepository, gitHubRepositoryOwner
|
|
15
|
+
* @populates gitHubBranch
|
|
16
|
+
*/
|
|
17
|
+
class GitHubBranchListStep extends vscode_azext_utils_1.AzureWizardPromptStep {
|
|
18
|
+
picks;
|
|
19
|
+
async prompt(context) {
|
|
20
|
+
// We always want fresh picks before prompting in case the user has pressed the back button
|
|
21
|
+
this.picks = [];
|
|
22
|
+
const placeHolder = vscode_1.l10n.t('Select a branch');
|
|
23
|
+
let page = 0;
|
|
24
|
+
while (!context.gitHubBranch) {
|
|
25
|
+
page++;
|
|
26
|
+
context.gitHubBranch = (await context.ui.showQuickPick(this.getPicks(context, page), { placeHolder })).data;
|
|
27
|
+
}
|
|
28
|
+
context.valuesToMask.push(context.gitHubBranch);
|
|
29
|
+
}
|
|
30
|
+
shouldPrompt(context) {
|
|
31
|
+
return !context.gitHubBranch;
|
|
32
|
+
}
|
|
33
|
+
async getPicks(context, page) {
|
|
34
|
+
const perPage = 50;
|
|
35
|
+
const branchParams = {
|
|
36
|
+
owner: (0, vscode_azext_utils_1.nonNullProp)(context, 'gitHubRepositoryOwner'),
|
|
37
|
+
repo: (0, vscode_azext_utils_1.nonNullProp)(context, 'gitHubRepository'),
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
39
|
+
per_page: perPage,
|
|
40
|
+
page
|
|
41
|
+
};
|
|
42
|
+
const branches = await (0, getBranches_1.getBranches)(context, branchParams);
|
|
43
|
+
this.picks.push(...branches.map((branch) => { return { label: branch.name, data: branch.name }; }));
|
|
44
|
+
this.picks.sort((a, b) => {
|
|
45
|
+
if (a.label === 'main' || a.label === 'master') {
|
|
46
|
+
return -1;
|
|
47
|
+
}
|
|
48
|
+
else if (b.label === 'main' || b.label === 'master') {
|
|
49
|
+
return 1;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return a.label.localeCompare(b.label);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const maxAvailablePicks = perPage * page;
|
|
56
|
+
return maxAvailablePicks === this.picks.length ? [...this.picks, constants_1.loadMoreQp] : this.picks;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.GitHubBranchListStep = GitHubBranchListStep;
|
|
60
|
+
//# sourceMappingURL=GitHubBranchListStep.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
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.GitHubOrgListStep = void 0;
|
|
8
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
9
|
+
const vscode_1 = require("vscode");
|
|
10
|
+
const getAuthenticatedUser_1 = require("../wrappers/getAuthenticatedUser");
|
|
11
|
+
const getOrgs_1 = require("../wrappers/getOrgs");
|
|
12
|
+
/**
|
|
13
|
+
* Used to prompt the user for the repository's GitHub organization
|
|
14
|
+
* @populates gitHubOrg
|
|
15
|
+
*/
|
|
16
|
+
class GitHubOrgListStep extends vscode_azext_utils_1.AzureWizardPromptStep {
|
|
17
|
+
async prompt(context) {
|
|
18
|
+
const placeHolder = vscode_1.l10n.t('Select an organization');
|
|
19
|
+
context.gitHubOrg = (await context.ui.showQuickPick(this.getPicks(context), { placeHolder })).data;
|
|
20
|
+
if (context.gitHubOrg) {
|
|
21
|
+
context.valuesToMask.push(context.gitHubOrg);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
shouldPrompt(context) {
|
|
25
|
+
return !context.gitHubOrg;
|
|
26
|
+
}
|
|
27
|
+
async getPicks(context) {
|
|
28
|
+
const user = await (0, getAuthenticatedUser_1.getAuthenticatedUser)(context);
|
|
29
|
+
const orgs = await (0, getOrgs_1.getOrgs)(context);
|
|
30
|
+
return [
|
|
31
|
+
{ label: user.login, data: undefined },
|
|
32
|
+
...orgs.map((org) => {
|
|
33
|
+
return { label: org.login, data: org.login };
|
|
34
|
+
})
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.GitHubOrgListStep = GitHubOrgListStep;
|
|
39
|
+
//# sourceMappingURL=GitHubOrgListStep.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
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.GitHubRepositoryListStep = void 0;
|
|
8
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
9
|
+
const vscode_1 = require("vscode");
|
|
10
|
+
const constants_1 = require("../constants");
|
|
11
|
+
const getRepositories_1 = require("../wrappers/getRepositories");
|
|
12
|
+
/**
|
|
13
|
+
* Used to prompt the user for the GitHub repository
|
|
14
|
+
* @prerequisites gitHubOrg
|
|
15
|
+
* @populates gitHubRepository, gitHubRepositoryOwner, gitHubRepositoryUrl
|
|
16
|
+
*/
|
|
17
|
+
class GitHubRepositoryListStep extends vscode_azext_utils_1.AzureWizardPromptStep {
|
|
18
|
+
picks;
|
|
19
|
+
async prompt(context) {
|
|
20
|
+
// We always want fresh picks before prompting in case the user has pressed the back button
|
|
21
|
+
this.picks = [];
|
|
22
|
+
const placeHolder = vscode_1.l10n.t('Select a repository');
|
|
23
|
+
let page = 0;
|
|
24
|
+
let repositoryData;
|
|
25
|
+
while (!repositoryData) {
|
|
26
|
+
page++;
|
|
27
|
+
repositoryData = (await context.ui.showQuickPick(this.getPicks(context, page), { placeHolder })).data;
|
|
28
|
+
}
|
|
29
|
+
context.gitHubRepository = repositoryData.repo;
|
|
30
|
+
context.gitHubRepositoryOwner = repositoryData.owner;
|
|
31
|
+
context.gitHubRepositoryUrl = repositoryData.url;
|
|
32
|
+
context.valuesToMask.push(context.gitHubRepository);
|
|
33
|
+
context.valuesToMask.push(context.gitHubRepositoryOwner);
|
|
34
|
+
context.valuesToMask.push(context.gitHubRepositoryUrl);
|
|
35
|
+
}
|
|
36
|
+
shouldPrompt(context) {
|
|
37
|
+
return !context.gitHubRepository || !context.gitHubRepositoryOwner;
|
|
38
|
+
}
|
|
39
|
+
async getPicks(context, page) {
|
|
40
|
+
const perPage = 50;
|
|
41
|
+
const userRepoParams = {
|
|
42
|
+
affiliation: 'owner',
|
|
43
|
+
visibility: 'all',
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
45
|
+
per_page: perPage,
|
|
46
|
+
page
|
|
47
|
+
};
|
|
48
|
+
const orgRepoParams = {
|
|
49
|
+
// Doesn't matter if context.gitHubOrg is undefined; that just means we will end up calling 'getRepositoriesByUser' instead
|
|
50
|
+
org: context.gitHubOrg ?? '',
|
|
51
|
+
type: 'all',
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
53
|
+
per_page: perPage,
|
|
54
|
+
page
|
|
55
|
+
};
|
|
56
|
+
// Intentionally use the same map callback on two lines below to force TypeScript to infer the proper repo type
|
|
57
|
+
this.picks.push(...(context.gitHubOrg ?
|
|
58
|
+
(await (0, getRepositories_1.getRepositoriesByOrg)(context, orgRepoParams)).map((repo) => { return { label: repo.name, data: { owner: repo.owner.login, repo: repo.name, url: repo.html_url } }; }) :
|
|
59
|
+
(await (0, getRepositories_1.getRepositoriesByUser)(context, userRepoParams)).map((repo) => { return { label: repo.name, data: { owner: repo.owner.login, repo: repo.name, url: repo.html_url } }; })));
|
|
60
|
+
this.picks.sort((a, b) => a.label.localeCompare(b.label));
|
|
61
|
+
const maxPicksAvailable = perPage * page;
|
|
62
|
+
return (maxPicksAvailable === this.picks.length) ? [...this.picks, constants_1.loadMoreQp] : this.picks;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.GitHubRepositoryListStep = GitHubRepositoryListStep;
|
|
66
|
+
//# sourceMappingURL=GitHubRepositoryListStep.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
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.getActions = getActions;
|
|
8
|
+
const createOctokitClient_1 = require("../createOctokitClient");
|
|
9
|
+
/**
|
|
10
|
+
* A wrapper for Octokit's: `client.actions.listWorkflowRunsForRepo`
|
|
11
|
+
*/
|
|
12
|
+
async function getActions(context, params) {
|
|
13
|
+
const client = await (0, createOctokitClient_1.createOctokitClient)(context);
|
|
14
|
+
return (await client.actions.listWorkflowRunsForRepo(params)).data;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=getActions.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
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.getAuthenticatedUser = getAuthenticatedUser;
|
|
8
|
+
const createOctokitClient_1 = require("../createOctokitClient");
|
|
9
|
+
/**
|
|
10
|
+
* A wrapper for Octokit's: `client.users.getAuthenticated`
|
|
11
|
+
*/
|
|
12
|
+
async function getAuthenticatedUser(context) {
|
|
13
|
+
const client = await (0, createOctokitClient_1.createOctokitClient)(context);
|
|
14
|
+
return (await client.users.getAuthenticated()).data;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=getAuthenticatedUser.js.map
|