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