@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.
Files changed (79) hide show
  1. package/dist/cjs/src/createOctokitClient.js +24 -0
  2. package/dist/cjs/src/extensionVariables.js +16 -0
  3. package/{out → dist/cjs}/src/index.js +3 -1
  4. package/dist/cjs/src/tree/ActionItem.js +79 -0
  5. package/dist/cjs/src/tree/ActionsItemBase.js +104 -0
  6. package/{out → dist/cjs}/src/tree/JobItem.js +15 -18
  7. package/{out → dist/cjs}/src/tree/StepItem.js +13 -4
  8. package/{out → dist/cjs}/src/utils/actionUtils.js +11 -9
  9. package/dist/cjs/src/utils/getGitHubAccessToken.js +30 -0
  10. package/{out → dist/cjs}/src/utils/gitHubUrlParse.js +4 -5
  11. package/dist/cjs/src/wizard/GitHubBranchListStep.js +60 -0
  12. package/dist/cjs/src/wizard/GitHubOrgListStep.js +39 -0
  13. package/dist/cjs/src/wizard/GitHubRepositoryListStep.js +66 -0
  14. package/dist/cjs/src/wrappers/getActions.js +16 -0
  15. package/dist/cjs/src/wrappers/getAuthenticatedUser.js +16 -0
  16. package/dist/cjs/src/wrappers/getBranches.js +16 -0
  17. package/dist/cjs/src/wrappers/getJobs.js +16 -0
  18. package/dist/cjs/src/wrappers/getOrgs.js +16 -0
  19. package/dist/cjs/src/wrappers/getRepositories.js +24 -0
  20. package/dist/esm/src/GitHubContext.js +6 -0
  21. package/dist/esm/src/constants.js +10 -0
  22. package/{out → dist/esm}/src/createOctokitClient.d.ts +1 -1
  23. package/dist/esm/src/createOctokitClient.js +21 -0
  24. package/dist/esm/src/extensionVariables.d.ts +6 -0
  25. package/dist/esm/src/extensionVariables.js +13 -0
  26. package/{out → dist/esm}/src/index.d.ts +1 -1
  27. package/dist/esm/src/index.js +23 -0
  28. package/{out → dist/esm}/src/tree/ActionItem.d.ts +6 -6
  29. package/dist/esm/src/tree/ActionItem.js +75 -0
  30. package/{out → dist/esm}/src/tree/ActionsItemBase.d.ts +3 -3
  31. package/dist/esm/src/tree/ActionsItemBase.js +100 -0
  32. package/{out → dist/esm}/src/tree/JobItem.d.ts +6 -6
  33. package/dist/esm/src/tree/JobItem.js +44 -0
  34. package/{out → dist/esm}/src/tree/StepItem.d.ts +6 -6
  35. package/dist/esm/src/tree/StepItem.js +38 -0
  36. package/dist/esm/src/utils/actionUtils.js +122 -0
  37. package/dist/esm/src/utils/getGitHubAccessToken.js +27 -0
  38. package/dist/esm/src/utils/gitHubUrlParse.js +19 -0
  39. package/dist/esm/src/wizard/GitHubBranchListStep.js +56 -0
  40. package/dist/esm/src/wizard/GitHubOrgListStep.js +35 -0
  41. package/dist/esm/src/wizard/GitHubRepositoryListStep.js +62 -0
  42. package/dist/esm/src/wrappers/getActions.js +13 -0
  43. package/dist/esm/src/wrappers/getAuthenticatedUser.js +13 -0
  44. package/dist/esm/src/wrappers/getBranches.js +13 -0
  45. package/dist/esm/src/wrappers/getJobs.js +13 -0
  46. package/dist/esm/src/wrappers/getOrgs.js +13 -0
  47. package/dist/esm/src/wrappers/getRepositories.js +20 -0
  48. package/package.json +18 -24
  49. package/out/src/createOctokitClient.js +0 -36
  50. package/out/src/extensionVariables.d.ts +0 -13
  51. package/out/src/extensionVariables.js +0 -43
  52. package/out/src/tree/ActionItem.js +0 -81
  53. package/out/src/tree/ActionsItemBase.js +0 -114
  54. package/out/src/utils/getGitHubAccessToken.js +0 -42
  55. package/out/src/wizard/GitHubBranchListStep.js +0 -71
  56. package/out/src/wizard/GitHubOrgListStep.js +0 -52
  57. package/out/src/wizard/GitHubRepositoryListStep.js +0 -77
  58. package/out/src/wrappers/getActions.js +0 -28
  59. package/out/src/wrappers/getAuthenticatedUser.js +0 -28
  60. package/out/src/wrappers/getBranches.js +0 -28
  61. package/out/src/wrappers/getJobs.js +0 -28
  62. package/out/src/wrappers/getOrgs.js +0 -28
  63. package/out/src/wrappers/getRepositories.js +0 -38
  64. /package/{out → dist/cjs}/src/GitHubContext.js +0 -0
  65. /package/{out → dist/cjs}/src/constants.js +0 -0
  66. /package/{out → dist/esm}/src/GitHubContext.d.ts +0 -0
  67. /package/{out → dist/esm}/src/constants.d.ts +0 -0
  68. /package/{out → dist/esm}/src/utils/actionUtils.d.ts +0 -0
  69. /package/{out → dist/esm}/src/utils/getGitHubAccessToken.d.ts +0 -0
  70. /package/{out → dist/esm}/src/utils/gitHubUrlParse.d.ts +0 -0
  71. /package/{out → dist/esm}/src/wizard/GitHubBranchListStep.d.ts +0 -0
  72. /package/{out → dist/esm}/src/wizard/GitHubOrgListStep.d.ts +0 -0
  73. /package/{out → dist/esm}/src/wizard/GitHubRepositoryListStep.d.ts +0 -0
  74. /package/{out → dist/esm}/src/wrappers/getActions.d.ts +0 -0
  75. /package/{out → dist/esm}/src/wrappers/getAuthenticatedUser.d.ts +0 -0
  76. /package/{out → dist/esm}/src/wrappers/getBranches.d.ts +0 -0
  77. /package/{out → dist/esm}/src/wrappers/getJobs.d.ts +0 -0
  78. /package/{out → dist/esm}/src/wrappers/getOrgs.d.ts +0 -0
  79. /package/{out → dist/esm}/src/wrappers/getRepositories.d.ts +0 -0
@@ -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,19 @@
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
+ // eslint-disable-next-line @typescript-eslint/prefer-regexp-exec
12
+ const match = url.match(/github\.com\/(?<ownerOrOrganization>[^/]+)\/(?<repositoryName>[^/]+)/i);
13
+ return {
14
+ urlReference: url,
15
+ ownerOrOrganization: match?.groups?.ownerOrOrganization,
16
+ repositoryName: match?.groups?.repositoryName
17
+ };
18
+ }
19
+ //# sourceMappingURL=gitHubUrlParse.js.map
@@ -0,0 +1,56 @@
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
+ // eslint-disable-next-line @typescript-eslint/naming-convention
36
+ per_page: perPage,
37
+ page
38
+ };
39
+ const branches = await getBranches(context, branchParams);
40
+ this.picks.push(...branches.map((branch) => { return { label: branch.name, data: branch.name }; }));
41
+ this.picks.sort((a, b) => {
42
+ if (a.label === 'main' || a.label === 'master') {
43
+ return -1;
44
+ }
45
+ else if (b.label === 'main' || b.label === 'master') {
46
+ return 1;
47
+ }
48
+ else {
49
+ return a.label.localeCompare(b.label);
50
+ }
51
+ });
52
+ const maxAvailablePicks = perPage * page;
53
+ return maxAvailablePicks === this.picks.length ? [...this.picks, loadMoreQp] : this.picks;
54
+ }
55
+ }
56
+ //# sourceMappingURL=GitHubBranchListStep.js.map
@@ -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,62 @@
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
+ // eslint-disable-next-line @typescript-eslint/naming-convention
42
+ per_page: perPage,
43
+ page
44
+ };
45
+ const orgRepoParams = {
46
+ // Doesn't matter if context.gitHubOrg is undefined; that just means we will end up calling 'getRepositoriesByUser' instead
47
+ org: context.gitHubOrg ?? '',
48
+ type: 'all',
49
+ // eslint-disable-next-line @typescript-eslint/naming-convention
50
+ per_page: perPage,
51
+ page
52
+ };
53
+ // Intentionally use the same map callback on two lines below to force TypeScript to infer the proper repo type
54
+ this.picks.push(...(context.gitHubOrg ?
55
+ (await getRepositoriesByOrg(context, orgRepoParams)).map((repo) => { return { label: repo.name, data: { owner: repo.owner.login, repo: repo.name, url: repo.html_url } }; }) :
56
+ (await getRepositoriesByUser(context, userRepoParams)).map((repo) => { return { label: repo.name, data: { owner: repo.owner.login, repo: repo.name, url: repo.html_url } }; })));
57
+ this.picks.sort((a, b) => a.label.localeCompare(b.label));
58
+ const maxPicksAvailable = perPage * page;
59
+ return (maxPicksAvailable === this.picks.length) ? [...this.picks, loadMoreQp] : this.picks;
60
+ }
61
+ }
62
+ //# sourceMappingURL=GitHubRepositoryListStep.js.map
@@ -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,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,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,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,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
@@ -0,0 +1,20 @@
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.listForAuthenticatedUser`
8
+ */
9
+ export async function getRepositoriesByUser(context, reqParams) {
10
+ const client = await createOctokitClient(context);
11
+ return (await client.repos.listForAuthenticatedUser(reqParams)).data;
12
+ }
13
+ /**
14
+ * A wrapper for Octokit's: `client.repos.listForOrg`
15
+ */
16
+ export async function getRepositoriesByOrg(context, reqParams) {
17
+ const client = await createOctokitClient(context);
18
+ return (await client.repos.listForOrg(reqParams)).data;
19
+ }
20
+ //# sourceMappingURL=getRepositories.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@microsoft/vscode-azext-github",
3
3
  "author": "Microsoft Corporation",
4
- "version": "1.0.7",
4
+ "version": "2.0.1",
5
5
  "description": "Common GitHub tools for VS Code",
6
6
  "tags": [
7
7
  "azure",
@@ -11,8 +11,9 @@
11
11
  "azure",
12
12
  "vscode"
13
13
  ],
14
- "main": "out/src/index.js",
15
- "types": "out/src/index.d.ts",
14
+ "module": "dist/esm/src/index.js",
15
+ "main": "dist/cjs/src/index.js",
16
+ "types": "dist/esm/src/index.d.ts",
16
17
  "license": "MIT",
17
18
  "repository": {
18
19
  "type": "git",
@@ -23,32 +24,25 @@
23
24
  },
24
25
  "homepage": "https://github.com/Microsoft/vscode-azuretools/blob/main/github/README.md",
25
26
  "scripts": {
26
- "build": "tsc -p ./",
27
- "compile": "tsc -watch -p ./",
28
- "lint": "eslint --ext .ts .",
29
- "lint-fix": "eslint --ext .ts . --fix",
27
+ "build": "npm run build:esm && npm run build:cjs",
28
+ "build:esm": "tsc -p ./",
29
+ "build:cjs": "tsc -p ./ --outDir ./dist/cjs --module nodenext --moduleResolution nodenext --declaration false",
30
+ "lint": "eslint --max-warnings 0",
30
31
  "package": "npm pack",
31
- "test": "node ./out/test/runTest.js",
32
+ "test": "exit 0",
32
33
  "l10n": "npx @vscode/l10n-dev export --outDir ./l10n ./src"
33
34
  },
35
+ "engines": {
36
+ "vscode": "^1.105.0"
37
+ },
34
38
  "devDependencies": {
35
- "@microsoft/eslint-config-azuretools": "^0.2.1",
36
- "@types/glob": "^8.1.0",
37
- "@types/mocha": "^7.0.2",
38
- "@types/node": "^16.0.0",
39
- "@types/vscode": "1.95.0",
40
- "@typescript-eslint/eslint-plugin": "^5.53.0",
41
- "@vscode/test-electron": "^2.3.8",
42
- "eslint": "^8.34.0",
43
- "eslint-plugin-import": "^2.22.1",
44
- "glob": "^7.1.6",
45
- "mocha": "^10.8.2",
46
- "mocha-junit-reporter": "^2.0.2",
47
- "mocha-multi-reporters": "^1.1.7",
48
- "typescript": "^5.1.3"
39
+ "@microsoft/vscode-azext-eng": "1.0.0-alpha.12",
40
+ "@microsoft/vscode-azureresources-api": "^3.1.0",
41
+ "@types/node": "22.x",
42
+ "@types/vscode": "1.105.0"
49
43
  },
50
44
  "dependencies": {
51
- "@microsoft/vscode-azext-utils": "^3.4.2",
52
- "@octokit/rest": "^20.1.2"
45
+ "@microsoft/vscode-azext-utils": "^4.0.4",
46
+ "@octokit/rest": "^22.0.1"
53
47
  }
54
48
  }
@@ -1,36 +0,0 @@
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.createOctokitClient = void 0;
17
- const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
18
- const rest_1 = require("@octokit/rest");
19
- const getGitHubAccessToken_1 = require("./utils/getGitHubAccessToken");
20
- /**
21
- * Can be used to initialize a new Octokit client.
22
- *
23
- * Note: Typically does not need to be called directly by client extensions
24
- * unless implementing a custom behavior.
25
- */
26
- function createOctokitClient(context) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- context.gitHubAccessToken || (context.gitHubAccessToken = yield (0, getGitHubAccessToken_1.getGitHubAccessToken)());
29
- return new rest_1.Octokit({
30
- userAgent: (0, vscode_azext_utils_1.appendExtensionUserAgent)(),
31
- auth: context.gitHubAccessToken
32
- });
33
- });
34
- }
35
- exports.createOctokitClient = createOctokitClient;
36
- //# sourceMappingURL=createOctokitClient.js.map
@@ -1,13 +0,0 @@
1
- import { UIExtensionVariables } from '@microsoft/vscode-azext-utils';
2
- interface IAzureUtilsExtensionVariables extends UIExtensionVariables {
3
- prefix: string;
4
- }
5
- /**
6
- * Container for common extension variables used throughout the github package. They must be initialized with `registerGitHubExtensionVariables`
7
- */
8
- export declare let ext: IAzureUtilsExtensionVariables;
9
- /**
10
- * Call this to register common variables used throughout the github package.
11
- */
12
- export declare function registerGitHubExtensionVariables(extVars: IAzureUtilsExtensionVariables): void;
13
- export {};
@@ -1,43 +0,0 @@
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 = exports.ext = void 0;
8
- const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
9
- const vscode_1 = require("vscode");
10
- class UninitializedExtensionVariables {
11
- constructor() {
12
- this._error = new Error(vscode_1.l10n.t('"registerGitHubExtensionVariables" must be called before using the vscode-azext-github package.'));
13
- }
14
- get context() {
15
- throw this._error;
16
- }
17
- get outputChannel() {
18
- throw this._error;
19
- }
20
- get ui() {
21
- throw this._error;
22
- }
23
- get prefix() {
24
- throw this._error;
25
- }
26
- }
27
- /**
28
- * Container for common extension variables used throughout the github package. They must be initialized with `registerGitHubExtensionVariables`
29
- */
30
- exports.ext = new UninitializedExtensionVariables();
31
- /**
32
- * Call this to register common variables used throughout the github package.
33
- */
34
- function registerGitHubExtensionVariables(extVars) {
35
- if (exports.ext === extVars) {
36
- // already registered
37
- return;
38
- }
39
- exports.ext = extVars;
40
- (0, vscode_azext_utils_1.registerUIExtensionVariables)(extVars);
41
- }
42
- exports.registerGitHubExtensionVariables = registerGitHubExtensionVariables;
43
- //# sourceMappingURL=extensionVariables.js.map
@@ -1,81 +0,0 @@
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.ActionItem = void 0;
17
- const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
18
- const vscode_1 = require("vscode");
19
- const actionUtils_1 = require("../utils/actionUtils");
20
- const gitHubUrlParse_1 = require("../utils/gitHubUrlParse");
21
- const getJobs_1 = require("../wrappers/getJobs");
22
- const JobItem_1 = require("./JobItem");
23
- class ActionItem {
24
- constructor(parentResourceId, extensionPrefixContextValue, actionWorkflowRuns) {
25
- var _a;
26
- this.parentResourceId = parentResourceId;
27
- this.extensionPrefixContextValue = extensionPrefixContextValue;
28
- this.actionWorkflowRuns = actionWorkflowRuns;
29
- this.id = `${this.parentResourceId}/${this.actionWorkflowRuns.id}`;
30
- this.label = ((_a = this.actionWorkflowRuns.head_commit) === null || _a === void 0 ? void 0 : _a.message) || this.actionWorkflowRuns.head_sha;
31
- this.viewProperties = {
32
- data: this.actionWorkflowRuns,
33
- label: this.label,
34
- };
35
- }
36
- get contextValue() {
37
- const actionTreeItemContextValue = `${this.extensionPrefixContextValue}${ActionItem.contextValueSuffix}`;
38
- const values = [actionTreeItemContextValue];
39
- if ((0, vscode_azext_utils_1.nonNullProp)(this.actionWorkflowRuns, 'status') === actionUtils_1.Status.Completed) {
40
- values.push(ActionItem.completedContextValue);
41
- }
42
- else {
43
- values.push(ActionItem.inProgressContextValue);
44
- }
45
- return (0, vscode_azext_utils_1.createContextValue)(values);
46
- }
47
- getTreeItem() {
48
- return {
49
- id: this.id,
50
- label: this.label,
51
- description: this.actionWorkflowRuns.event,
52
- iconPath: (0, actionUtils_1.getActionBasedIconPath)(this.actionWorkflowRuns),
53
- contextValue: this.contextValue,
54
- collapsibleState: vscode_1.TreeItemCollapsibleState.Collapsed
55
- };
56
- }
57
- getChildren() {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- const jobsData = yield (0, vscode_azext_utils_1.callWithTelemetryAndErrorHandling)('getActionChildren', (context) => __awaiter(this, void 0, void 0, function* () {
60
- const { ownerOrOrganization, repositoryName } = (0, gitHubUrlParse_1.gitHubUrlParse)(this.actionWorkflowRuns.repository.html_url);
61
- const getJobsParams = {
62
- owner: (0, vscode_azext_utils_1.nonNullValue)(ownerOrOrganization),
63
- repo: (0, vscode_azext_utils_1.nonNullValue)(repositoryName),
64
- run_id: this.actionWorkflowRuns.id
65
- };
66
- return yield (0, getJobs_1.getJobs)(context, getJobsParams);
67
- }));
68
- if (jobsData === null || jobsData === void 0 ? void 0 : jobsData.total_count) {
69
- return jobsData.jobs.map((job) => new JobItem_1.JobItem(this.id, this.extensionPrefixContextValue, job));
70
- }
71
- else {
72
- return [];
73
- }
74
- });
75
- }
76
- }
77
- exports.ActionItem = ActionItem;
78
- ActionItem.contextValueSuffix = 'ActionItem';
79
- ActionItem.completedContextValue = 'actionState:completed';
80
- ActionItem.inProgressContextValue = 'actionState:inProgress';
81
- //# sourceMappingURL=ActionItem.js.map