GitHub - revert ESM migration (#247322)

* Revert "fix github extension bundling (#247314)"

This reverts commit 0cffb673f5.

* Revert "migrate github-extension to ESM"

This reverts commit 493874c390.

* Add missing JS file
This commit is contained in:
Ladislau Szomoru
2025-04-24 18:24:59 +01:00
committed by GitHub
parent cb6da5bcc3
commit 2047ab0fff
22 changed files with 280 additions and 225 deletions

View File

@@ -5,7 +5,7 @@
import { AuthenticationSession, authentication, window } from 'vscode';
import { Agent, globalAgent } from 'https';
import { graphql } from '@octokit/graphql/types';
import { graphql } from '@octokit/graphql/dist-types/types';
import { Octokit } from '@octokit/rest';
import { httpsOverHttp } from 'tunnel';
import { URL } from 'url';
@@ -71,7 +71,7 @@ export async function getOctokitGraphql(): Promise<graphql> {
const token = session.accessToken;
const { graphql } = await import('@octokit/graphql');
return graphql({
return graphql.defaults({
headers: {
authorization: `token ${token}`
},

View File

@@ -5,9 +5,9 @@
import { authentication, EventEmitter, LogOutputChannel, Memento, Uri, workspace } from 'vscode';
import { Repository as GitHubRepository, RepositoryRuleset } from '@octokit/graphql-schema';
import { AuthenticationError, getOctokitGraphql } from './auth.js';
import { API, BranchProtection, BranchProtectionProvider, BranchProtectionRule, Repository } from './typings/git.js';
import { DisposableStore, getRepositoryFromUrl } from './util.js';
import { AuthenticationError, getOctokitGraphql } from './auth';
import { API, BranchProtection, BranchProtectionProvider, BranchProtectionRule, Repository } from './typings/git';
import { DisposableStore, getRepositoryFromUrl } from './util';
import TelemetryReporter from '@vscode/extension-telemetry';
const REPOSITORY_QUERY = `
@@ -74,7 +74,7 @@ export class GitHubBranchProtectionProviderManager {
private readonly gitAPI: API,
private readonly globalState: Memento,
private readonly logger: LogOutputChannel,
private readonly telemetryReporter: TelemetryReporter.default) {
private readonly telemetryReporter: TelemetryReporter) {
this.disposables.add(this.gitAPI.onDidOpenRepository(repository => {
if (this._enabled) {
this.providerDisposables.add(gitAPI.registerBranchProtectionProvider(repository.rootUri, new GitHubBranchProtectionProvider(repository, this.globalState, this.logger, this.telemetryReporter)));
@@ -113,7 +113,7 @@ export class GitHubBranchProtectionProvider implements BranchProtectionProvider
private readonly repository: Repository,
private readonly globalState: Memento,
private readonly logger: LogOutputChannel,
private readonly telemetryReporter: TelemetryReporter.default) {
private readonly telemetryReporter: TelemetryReporter) {
// Restore branch protection from global state
this.branchProtection = this.globalState.get<BranchProtection[]>(this.globalStateKey, []);

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { CancellationToken, CanonicalUriProvider, CanonicalUriRequestOptions, Disposable, ProviderResult, Uri, workspace } from 'vscode';
import { API } from './typings/git.js';
import { API } from './typings/git';
const SUPPORTED_SCHEMES = ['ssh', 'https', 'file'];

View File

@@ -4,10 +4,10 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { API as GitAPI, RefType, Repository } from './typings/git.js';
import { publishRepository } from './publish.js';
import { DisposableStore, getRepositoryFromUrl } from './util.js';
import { LinkContext, getCommitLink, getLink, getVscodeDevHost } from './links.js';
import { API as GitAPI, RefType, Repository } from './typings/git';
import { publishRepository } from './publish';
import { DisposableStore, getRepositoryFromUrl } from './util';
import { LinkContext, getCommitLink, getLink, getVscodeDevHost } from './links';
async function copyVscodeDevLink(gitAPI: GitAPI, useSelection: boolean, context: LinkContext, includeRange = true) {
try {

View File

@@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { CredentialsProvider, Credentials, API as GitAPI } from './typings/git.js';
import { CredentialsProvider, Credentials, API as GitAPI } from './typings/git';
import { workspace, Uri, Disposable } from 'vscode';
import { getSession } from './auth.js';
import { getSession } from './auth';
const EmptyDisposable: Disposable = { dispose() { } };

View File

@@ -5,18 +5,18 @@
import { commands, Disposable, ExtensionContext, extensions, l10n, LogLevel, LogOutputChannel, window } from 'vscode';
import TelemetryReporter from '@vscode/extension-telemetry';
import { GithubRemoteSourceProvider } from './remoteSourceProvider.js';
import { API, GitExtension } from './typings/git.js';
import { registerCommands } from './commands.js';
import { GithubCredentialProviderManager } from './credentialProvider.js';
import { DisposableStore, repositoryHasGitHubRemote } from './util.js';
import { GithubPushErrorHandler } from './pushErrorHandler.js';
import { GitBaseExtension } from './typings/git-base.js';
import { GithubRemoteSourcePublisher } from './remoteSourcePublisher.js';
import { GitHubBranchProtectionProviderManager } from './branchProtection.js';
import { GitHubCanonicalUriProvider } from './canonicalUriProvider.js';
import { VscodeDevShareProvider } from './shareProviders.js';
import { GitHubSourceControlHistoryItemDetailsProvider } from './historyItemDetailsProvider.js';
import { GithubRemoteSourceProvider } from './remoteSourceProvider';
import { API, GitExtension } from './typings/git';
import { registerCommands } from './commands';
import { GithubCredentialProviderManager } from './credentialProvider';
import { DisposableStore, repositoryHasGitHubRemote } from './util';
import { GithubPushErrorHandler } from './pushErrorHandler';
import { GitBaseExtension } from './typings/git-base';
import { GithubRemoteSourcePublisher } from './remoteSourcePublisher';
import { GitHubBranchProtectionProviderManager } from './branchProtection';
import { GitHubCanonicalUriProvider } from './canonicalUriProvider';
import { VscodeDevShareProvider } from './shareProviders';
import { GitHubSourceControlHistoryItemDetailsProvider } from './historyItemDetailsProvider';
export function activate(context: ExtensionContext): void {
const disposables: Disposable[] = [];
@@ -31,8 +31,8 @@ export function activate(context: ExtensionContext): void {
disposables.push(logger.onDidChangeLogLevel(onDidChangeLogLevel));
onDidChangeLogLevel(logger.logLevel);
const { aiKey } = context.extension.packageJSON as { aiKey: string };
const telemetryReporter = new TelemetryReporter.default(aiKey);
const { aiKey } = require('../package.json') as { aiKey: string };
const telemetryReporter = new TelemetryReporter(aiKey);
disposables.push(telemetryReporter);
disposables.push(initializeGitBaseExtension());
@@ -84,7 +84,7 @@ function setGitHubContext(gitAPI: API, disposables: DisposableStore) {
}
}
function initializeGitExtension(context: ExtensionContext, telemetryReporter: TelemetryReporter.default, logger: LogOutputChannel): Disposable {
function initializeGitExtension(context: ExtensionContext, telemetryReporter: TelemetryReporter, logger: LogOutputChannel): Disposable {
const disposables = new DisposableStore();
let gitExtension = extensions.getExtension<GitExtension>('vscode.git');

View File

@@ -5,10 +5,10 @@
import { authentication, Command, l10n, LogOutputChannel, workspace } from 'vscode';
import { Commit, Repository as GitHubRepository, Maybe } from '@octokit/graphql-schema';
import { API, AvatarQuery, AvatarQueryCommit, Repository, SourceControlHistoryItemDetailsProvider } from './typings/git.js';
import { DisposableStore, getRepositoryDefaultRemote, getRepositoryDefaultRemoteUrl, getRepositoryFromUrl, groupBy, sequentialize } from './util.js';
import { AuthenticationError, getOctokitGraphql } from './auth.js';
import { getAvatarLink } from './links.js';
import { API, AvatarQuery, AvatarQueryCommit, Repository, SourceControlHistoryItemDetailsProvider } from './typings/git';
import { DisposableStore, getRepositoryDefaultRemote, getRepositoryDefaultRemoteUrl, getRepositoryFromUrl, groupBy, sequentialize } from './util';
import { AuthenticationError, getOctokitGraphql } from './auth';
import { getAvatarLink } from './links';
const ISSUE_EXPRESSION = /(([A-Za-z0-9_.\-]+)\/([A-Za-z0-9_.\-]+))?(#|GH-)([1-9][0-9]*)($|\b)/g;

View File

@@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { API as GitAPI, RefType, Repository } from './typings/git.js';
import { getRepositoryFromUrl, repositoryHasGitHubRemote } from './util.js';
import { API as GitAPI, RefType, Repository } from './typings/git';
import { getRepositoryFromUrl, repositoryHasGitHubRemote } from './util';
export function isFileInRepo(repository: Repository, file: vscode.Uri): boolean {
return file.path.toLowerCase() === repository.rootUri.path.toLowerCase() ||

View File

@@ -4,12 +4,12 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { API as GitAPI, Repository } from './typings/git.js';
import { getOctokit } from './auth.js';
import { API as GitAPI, Repository } from './typings/git';
import { getOctokit } from './auth';
import { TextEncoder } from 'util';
import { basename } from 'path';
import { Octokit } from '@octokit/rest';
import { isInCodespaces } from './pushErrorHandler.js';
import { isInCodespaces } from './pushErrorHandler';
function sanitizeRepositoryName(value: string): string {
return value.trim().replace(/[^a-z0-9_.]/ig, '-');

View File

@@ -5,12 +5,10 @@
import { TextDecoder } from 'util';
import { commands, env, ProgressLocation, Uri, window, workspace, QuickPickOptions, FileType, l10n, Disposable, TextDocumentContentProvider } from 'vscode';
import { getOctokit } from './auth.js';
import { GitErrorCodes, PushErrorHandler, Remote, Repository } from './typings/git.js';
import * as path from 'path';
import TelemetryReporter from '@vscode/extension-telemetry';
import { getOctokit } from './auth';
import { GitErrorCodes, PushErrorHandler, Remote, Repository } from './typings/git';
import * as path from 'path';
type Awaited<T> = T extends PromiseLike<infer U> ? Awaited<U> : T;
@@ -102,7 +100,7 @@ export class GithubPushErrorHandler implements PushErrorHandler {
private disposables: Disposable[] = [];
private commandErrors = new CommandErrorOutputTextDocumentContentProvider();
constructor(private readonly telemetryReporter: TelemetryReporter.default) {
constructor(private readonly telemetryReporter: TelemetryReporter) {
this.disposables.push(workspace.registerTextDocumentContentProvider('github-output', this.commandErrors));
}

View File

@@ -4,11 +4,11 @@
*--------------------------------------------------------------------------------------------*/
import { Uri, env, l10n, workspace } from 'vscode';
import { RemoteSourceProvider, RemoteSource, RemoteSourceAction } from './typings/git-base.js';
import { getOctokit } from './auth.js';
import { RemoteSourceProvider, RemoteSource, RemoteSourceAction } from './typings/git-base';
import { getOctokit } from './auth';
import { Octokit } from '@octokit/rest';
import { getRepositoryFromQuery, getRepositoryFromUrl } from './util.js';
import { getBranchLink, getVscodeDevHost } from './links.js';
import { getRepositoryFromQuery, getRepositoryFromUrl } from './util';
import { getBranchLink, getVscodeDevHost } from './links';
function asRemoteSource(raw: any): RemoteSource {
const protocol = workspace.getConfiguration('github').get<'https' | 'ssh'>('gitProtocol');

View File

@@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { publishRepository } from './publish.js';
import { API as GitAPI, RemoteSourcePublisher, Repository } from './typings/git.js';
import { publishRepository } from './publish';
import { API as GitAPI, RemoteSourcePublisher, Repository } from './typings/git';
export class GithubRemoteSourcePublisher implements RemoteSourcePublisher {
readonly name = 'GitHub';

View File

@@ -4,9 +4,9 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { API } from './typings/git.js';
import { getRepositoryFromUrl, repositoryHasGitHubRemote } from './util.js';
import { encodeURIComponentExceptSlashes, ensurePublished, getRepositoryForFile, notebookCellRangeString, rangeString } from './links.js';
import { API } from './typings/git';
import { getRepositoryFromUrl, repositoryHasGitHubRemote } from './util';
import { encodeURIComponentExceptSlashes, ensurePublished, getRepositoryForFile, notebookCellRangeString, rangeString } from './links';
export class VscodeDevShareProvider implements vscode.ShareProvider, vscode.Disposable {
readonly id: string = 'copyVscodeDevLink';

View File

@@ -6,7 +6,7 @@
import 'mocha';
import * as assert from 'assert';
import { workspace, extensions, Uri, commands } from 'vscode';
import { findPullRequestTemplates, pickPullRequestTemplate } from '../pushErrorHandler.js';
import { findPullRequestTemplates, pickPullRequestTemplate } from '../pushErrorHandler';
suite('github smoke test', function () {
const cwd = workspace.workspaceFolders![0].uri;

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
import * as testRunner from '../../../../test/integration/electron/testrunner.js';
import * as testRunner from '../../../../test/integration/electron/testrunner';
const suite = 'Github Tests';
@@ -27,4 +27,4 @@ if (process.env.BUILD_ARTIFACTSTAGINGDIRECTORY) {
testRunner.configure(options);
export default testRunner;
export = testRunner;

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { Repository } from './typings/git.js';
import { Repository } from './typings/git';
export class DisposableStore {