From 3940ef7c20cb446cb1a6c9e490470e26c38b61d5 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 1 Mar 2023 00:03:01 -0500 Subject: [PATCH] Moves some files for better organization Removes re-export of config from configuration --- src/annotations/annotationProvider.ts | 4 +- src/annotations/annotations.ts | 4 +- src/annotations/autolinks.ts | 6 +- src/annotations/blameAnnotationProvider.ts | 2 +- src/annotations/fileAnnotationController.ts | 13 +- src/annotations/gutterBlameAnnotationProvider.ts | 7 +- src/annotations/gutterChangesAnnotationProvider.ts | 5 +- .../gutterHeatmapBlameAnnotationProvider.ts | 4 +- src/annotations/lineAnnotationController.ts | 8 +- src/api/actionRunners.ts | 4 +- src/avatars.ts | 2 +- src/codelens/codeLensController.ts | 4 +- src/codelens/codeLensProvider.ts | 7 +- src/commands/browseRepoAtRevision.ts | 2 +- src/commands/closeUnchangedFiles.ts | 4 +- src/commands/compareWith.ts | 2 +- src/commands/copyCurrentBranch.ts | 2 +- src/commands/copyDeepLink.ts | 2 +- src/commands/copyMessageToClipboard.ts | 2 +- src/commands/copyShaToClipboard.ts | 4 +- src/commands/diffLineWithPrevious.ts | 2 +- src/commands/diffLineWithWorking.ts | 2 +- src/commands/diffWith.ts | 2 +- src/commands/diffWithNext.ts | 2 +- src/commands/diffWithPrevious.ts | 2 +- src/commands/diffWithRevision.ts | 2 +- src/commands/diffWithWorking.ts | 2 +- src/commands/externalDiff.ts | 4 +- src/commands/ghpr/openOrCreateWorktree.ts | 2 +- src/commands/git/push.ts | 2 +- src/commands/git/remote.ts | 2 +- src/commands/git/search.ts | 2 +- src/commands/git/stash.ts | 2 +- src/commands/git/worktree.ts | 4 +- src/commands/gitCommands.ts | 4 +- src/commands/gitCommands.utils.ts | 2 +- src/commands/logging.ts | 3 +- src/commands/openAssociatedPullRequestOnRemote.ts | 2 +- src/commands/openBranchOnRemote.ts | 2 +- src/commands/openBranchesOnRemote.ts | 2 +- src/commands/openChangedFiles.ts | 2 +- src/commands/openCommitOnRemote.ts | 2 +- src/commands/openComparisonOnRemote.ts | 2 +- src/commands/openCurrentBranchOnRemote.ts | 2 +- src/commands/openDirectoryCompare.ts | 2 +- src/commands/openFileAtRevision.ts | 4 +- src/commands/openFileAtRevisionFrom.ts | 2 +- src/commands/openFileOnRemote.ts | 6 +- src/commands/openOnRemote.ts | 2 +- src/commands/openRepoOnRemote.ts | 2 +- src/commands/openRevisionFile.ts | 4 +- src/commands/openWorkingFile.ts | 4 +- src/commands/quickCommand.steps.ts | 3 +- src/commands/quickCommand.ts | 4 +- src/commands/resets.ts | 2 +- src/commands/searchCommits.ts | 2 +- src/commands/setViewsLayout.ts | 2 +- src/commands/showCommitsInView.ts | 2 +- src/commands/showLastQuickPick.ts | 2 +- src/commands/showQuickCommit.ts | 2 +- src/commands/showQuickCommitFile.ts | 2 +- src/commands/switchMode.ts | 4 +- src/commands/toggleFileAnnotations.ts | 6 +- src/commands/toggleLineBlame.ts | 2 +- src/comparers.ts | 36 --- src/config.ts | 2 +- src/configuration.ts | 345 --------------------- src/constants.ts | 10 +- src/container.ts | 11 +- src/env/browser/platform.ts | 12 +- src/env/node/fetch.ts | 4 +- src/env/node/git/git.ts | 5 +- src/env/node/git/localGitProvider.ts | 8 +- src/env/node/git/locator.ts | 3 +- src/env/node/git/shell.ts | 2 +- src/env/node/git/vslsGitProvider.ts | 4 +- src/env/node/platform.ts | 12 +- src/env/node/providers.ts | 2 +- src/extension.ts | 10 +- src/git/formatters/commitFormatter.ts | 3 +- src/git/gitProviderService.ts | 6 +- src/git/gitUri.ts | 4 +- src/git/models/branch.ts | 5 +- src/git/models/commit.ts | 6 +- src/git/models/contributor.ts | 5 +- src/git/models/pullRequest.ts | 2 +- src/git/models/reference.ts | 2 +- src/git/models/repository.ts | 6 +- src/git/models/tag.ts | 5 +- src/git/remotes/custom.ts | 2 +- src/git/remotes/remoteProviders.ts | 6 +- src/git/remotes/richRemoteProvider.ts | 6 +- src/hovers/hovers.ts | 9 +- src/hovers/lineHoverController.ts | 7 +- src/keyboard.ts | 216 ------------- src/logScope.ts | 41 --- src/logger.ts | 254 --------------- src/messages.ts | 8 +- src/plus/github/github.ts | 10 +- src/plus/github/githubGitProvider.ts | 8 +- src/plus/gitlab/gitlab.ts | 10 +- src/plus/remotehub.ts | 2 +- src/plus/subscription/authenticationProvider.ts | 4 +- src/plus/subscription/serverConnection.ts | 4 +- src/plus/subscription/subscriptionService.ts | 6 +- src/plus/subscription/utils.ts | 2 +- src/plus/webviews/graph/graphWebview.ts | 4 +- src/plus/webviews/timeline/timelineWebview.ts | 2 +- src/plus/webviews/timeline/timelineWebviewView.ts | 2 +- src/quickpicks/commitPicker.ts | 4 +- src/quickpicks/items/commits.ts | 2 +- src/quickpicks/items/common.ts | 2 +- src/quickpicks/modePicker.ts | 2 +- src/quickpicks/referencePicker.ts | 2 +- src/quickpicks/remoteProviderPicker.ts | 2 +- src/statusbar/statusBarController.ts | 9 +- src/storage.ts | 2 +- src/system/comparers.ts | 36 +++ src/system/configuration.ts | 343 ++++++++++++++++++++ src/system/decorators/log.ts | 12 +- src/system/keyboard.ts | 218 +++++++++++++ src/system/logger.constants.ts | 9 + src/system/logger.scope.ts | 41 +++ src/system/logger.ts | 254 +++++++++++++++ src/system/stopwatch.ts | 11 +- src/system/utils.ts | 4 +- src/telemetry/telemetry.ts | 2 +- src/telemetry/usageTracker.ts | 104 +++++++ src/terminal.ts | 2 +- src/terminal/linkProvider.ts | 2 +- src/trackers/documentTracker.ts | 2 +- src/trackers/gitLineTracker.ts | 4 +- src/trackers/lineTracker.ts | 4 +- src/trackers/trackedDocument.ts | 2 +- src/uris/deepLinks/deepLinkService.ts | 4 +- src/usageTracker.ts | 104 ------- src/views/branchesView.ts | 5 +- src/views/commitsView.ts | 7 +- src/views/contributorsView.ts | 5 +- src/views/fileHistoryView.ts | 4 +- src/views/lineHistoryView.ts | 4 +- src/views/nodes/branchNode.ts | 4 +- src/views/nodes/branchTrackingStatusFilesNode.ts | 2 +- src/views/nodes/branchesNode.ts | 2 +- src/views/nodes/commitNode.ts | 3 +- src/views/nodes/common.ts | 2 +- src/views/nodes/compareBranchNode.ts | 2 +- src/views/nodes/contributorNode.ts | 2 +- src/views/nodes/contributorsNode.ts | 2 +- src/views/nodes/fileHistoryNode.ts | 4 +- src/views/nodes/fileHistoryTrackerNode.ts | 6 +- src/views/nodes/fileRevisionAsCommitNode.ts | 2 +- src/views/nodes/folderNode.ts | 4 +- src/views/nodes/lineHistoryNode.ts | 2 +- src/views/nodes/lineHistoryTrackerNode.ts | 6 +- src/views/nodes/mergeConflictCurrentChangesNode.ts | 2 +- .../nodes/mergeConflictIncomingChangesNode.ts | 2 +- src/views/nodes/mergeStatusNode.ts | 2 +- src/views/nodes/rebaseStatusNode.ts | 3 +- src/views/nodes/remoteNode.ts | 2 +- src/views/nodes/repositoriesNode.ts | 2 +- src/views/nodes/resultsCommitsNode.ts | 2 +- src/views/nodes/resultsFilesNode.ts | 2 +- src/views/nodes/stashNode.ts | 2 +- src/views/nodes/statusFilesNode.ts | 2 +- src/views/nodes/tagNode.ts | 2 +- src/views/nodes/tagsNode.ts | 2 +- src/views/nodes/viewNode.ts | 2 +- src/views/remotesView.ts | 5 +- src/views/repositoriesView.ts | 5 +- src/views/searchAndCompareView.ts | 5 +- src/views/stashesView.ts | 5 +- src/views/tagsView.ts | 5 +- src/views/viewBase.ts | 11 +- src/views/viewCommands.ts | 3 +- src/views/worktreesView.ts | 5 +- src/vsls/guest.ts | 4 +- src/vsls/host.ts | 4 +- src/vsls/vsls.ts | 4 +- src/webviews/apps/shared/appBase.ts | 4 +- .../commitDetails/commitDetailsWebviewView.ts | 6 +- src/webviews/home/homeWebviewView.ts | 2 +- src/webviews/protocol.ts | 2 +- src/webviews/rebase/rebaseEditor.ts | 4 +- src/webviews/settings/settingsWebview.ts | 2 +- src/webviews/webviewBase.ts | 2 +- src/webviews/webviewViewBase.ts | 6 +- src/webviews/webviewWithConfigBase.ts | 8 +- src/webviews/welcome/welcomeWebview.ts | 2 +- 189 files changed, 1351 insertions(+), 1336 deletions(-) delete mode 100644 src/comparers.ts delete mode 100644 src/configuration.ts delete mode 100644 src/keyboard.ts delete mode 100644 src/logScope.ts delete mode 100644 src/logger.ts create mode 100644 src/system/comparers.ts create mode 100644 src/system/configuration.ts create mode 100644 src/system/keyboard.ts create mode 100644 src/system/logger.constants.ts create mode 100644 src/system/logger.scope.ts create mode 100644 src/system/logger.ts create mode 100644 src/telemetry/usageTracker.ts delete mode 100644 src/usageTracker.ts diff --git a/src/annotations/annotationProvider.ts b/src/annotations/annotationProvider.ts index 2d5e74e..c80b420 100644 --- a/src/annotations/annotationProvider.ts +++ b/src/annotations/annotationProvider.ts @@ -8,10 +8,10 @@ import type { Uri, } from 'vscode'; import { Disposable, window } from 'vscode'; -import type { FileAnnotationType } from '../configuration'; +import type { FileAnnotationType } from '../config'; import { ContextKeys } from '../constants'; import { setContext } from '../context'; -import { Logger } from '../logger'; +import { Logger } from '../system/logger'; import type { GitDocumentState, TrackedDocument } from '../trackers/gitDocumentTracker'; export const enum AnnotationStatus { diff --git a/src/annotations/annotations.ts b/src/annotations/annotations.ts index 7410c6b..4a6ef82 100644 --- a/src/annotations/annotations.ts +++ b/src/annotations/annotations.ts @@ -7,14 +7,14 @@ import type { ThemableDecorationRenderOptions, } from 'vscode'; import { OverviewRulerLane, ThemeColor, Uri, window } from 'vscode'; +import type { Config } from '../config'; import { HeatmapLocations } from '../config'; -import type { Config } from '../configuration'; -import { configuration } from '../configuration'; import { Colors, GlyphChars } from '../constants'; import type { CommitFormatOptions } from '../git/formatters/commitFormatter'; import { CommitFormatter } from '../git/formatters/commitFormatter'; import type { GitCommit } from '../git/models/commit'; import { scale, toRgba } from '../system/color'; +import { configuration } from '../system/configuration'; import { getWidth, interpolate, pad } from '../system/string'; export interface ComputedHeatmap { diff --git a/src/annotations/autolinks.ts b/src/annotations/autolinks.ts index 2b43c82..36decf8 100644 --- a/src/annotations/autolinks.ts +++ b/src/annotations/autolinks.ts @@ -1,18 +1,18 @@ import type { ConfigurationChangeEvent } from 'vscode'; import { Disposable } from 'vscode'; -import type { AutolinkReference, AutolinkType } from '../configuration'; -import { configuration } from '../configuration'; +import type { AutolinkReference, AutolinkType } from '../config'; import { GlyphChars } from '../constants'; import type { Container } from '../container'; import type { IssueOrPullRequest } from '../git/models/issue'; import { getIssueOrPullRequestHtmlIcon, getIssueOrPullRequestMarkdownIcon } from '../git/models/issue'; import type { GitRemote } from '../git/models/remote'; import type { RemoteProviderReference } from '../git/models/remoteProvider'; -import { Logger } from '../logger'; +import { configuration } from '../system/configuration'; import { fromNow } from '../system/date'; import { debug } from '../system/decorators/log'; import { encodeUrl } from '../system/encoding'; import { join, map } from '../system/iterable'; +import { Logger } from '../system/logger'; import type { PromiseCancelledErrorWithId } from '../system/promise'; import { PromiseCancelledError, raceAll } from '../system/promise'; import { encodeHtmlWeak, escapeMarkdown, escapeRegex, getSuperscript } from '../system/string'; diff --git a/src/annotations/blameAnnotationProvider.ts b/src/annotations/blameAnnotationProvider.ts index beb2b51..2930b6c 100644 --- a/src/annotations/blameAnnotationProvider.ts +++ b/src/annotations/blameAnnotationProvider.ts @@ -1,12 +1,12 @@ import type { CancellationToken, Disposable, Position, TextDocument, TextEditor } from 'vscode'; import { Hover, languages, Range } from 'vscode'; import type { FileAnnotationType } from '../config'; -import { configuration } from '../configuration'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import type { GitBlame } from '../git/models/blame'; import type { GitCommit } from '../git/models/commit'; import { changesMessage, detailsMessage } from '../hovers/hovers'; +import { configuration } from '../system/configuration'; import { log } from '../system/decorators/log'; import type { GitDocumentState, TrackedDocument } from '../trackers/gitDocumentTracker'; import { AnnotationProviderBase } from './annotationProvider'; diff --git a/src/annotations/fileAnnotationController.ts b/src/annotations/fileAnnotationController.ts index 7286aa8..d096129 100644 --- a/src/annotations/fileAnnotationController.ts +++ b/src/annotations/fileAnnotationController.ts @@ -20,21 +20,16 @@ import { window, workspace, } from 'vscode'; -import { - AnnotationsToggleMode, - BlameHighlightLocations, - ChangesLocations, - configuration, - FileAnnotationType, -} from '../configuration'; +import { AnnotationsToggleMode, BlameHighlightLocations, ChangesLocations, FileAnnotationType } from '../config'; import { Colors, ContextKeys } from '../constants'; import type { Container } from '../container'; import { setContext } from '../context'; -import type { KeyboardScope } from '../keyboard'; -import { Logger } from '../logger'; +import { configuration } from '../system/configuration'; import { once } from '../system/event'; import { debounce } from '../system/function'; import { find } from '../system/iterable'; +import type { KeyboardScope } from '../system/keyboard'; +import { Logger } from '../system/logger'; import { basename } from '../system/path'; import { isTextEditor } from '../system/utils'; import type { diff --git a/src/annotations/gutterBlameAnnotationProvider.ts b/src/annotations/gutterBlameAnnotationProvider.ts index ef8df7d..4341a75 100644 --- a/src/annotations/gutterBlameAnnotationProvider.ts +++ b/src/annotations/gutterBlameAnnotationProvider.ts @@ -1,17 +1,18 @@ import type { DecorationOptions, TextEditor, ThemableDecorationAttachmentRenderOptions } from 'vscode'; import { Range } from 'vscode'; -import type { GravatarDefaultStyle } from '../configuration'; -import { configuration, FileAnnotationType } from '../configuration'; +import type { GravatarDefaultStyle } from '../config'; +import { FileAnnotationType } from '../config'; import { GlyphChars } from '../constants'; import type { Container } from '../container'; import type { CommitFormatOptions } from '../git/formatters/commitFormatter'; import { CommitFormatter } from '../git/formatters/commitFormatter'; import type { GitBlame } from '../git/models/blame'; import type { GitCommit } from '../git/models/commit'; -import { getLogScope } from '../logScope'; import { filterMap } from '../system/array'; +import { configuration } from '../system/configuration'; import { log } from '../system/decorators/log'; import { first } from '../system/iterable'; +import { getLogScope } from '../system/logger.scope'; import { Stopwatch } from '../system/stopwatch'; import type { TokenOptions } from '../system/string'; import { getTokensFromTemplate, getWidth } from '../system/string'; diff --git a/src/annotations/gutterChangesAnnotationProvider.ts b/src/annotations/gutterChangesAnnotationProvider.ts index c68f53e..485f3f0 100644 --- a/src/annotations/gutterChangesAnnotationProvider.ts +++ b/src/annotations/gutterChangesAnnotationProvider.ts @@ -7,13 +7,14 @@ import type { TextEditorDecorationType, } from 'vscode'; import { Hover, languages, Position, Range, Selection, TextEditorRevealType } from 'vscode'; -import { configuration, FileAnnotationType } from '../configuration'; +import { FileAnnotationType } from '../config'; import type { Container } from '../container'; import type { GitCommit } from '../git/models/commit'; import type { GitDiff } from '../git/models/diff'; import { localChangesMessage } from '../hovers/hovers'; -import { getLogScope } from '../logScope'; +import { configuration } from '../system/configuration'; import { log } from '../system/decorators/log'; +import { getLogScope } from '../system/logger.scope'; import { Stopwatch } from '../system/stopwatch'; import type { GitDocumentState, TrackedDocument } from '../trackers/gitDocumentTracker'; import type { AnnotationContext } from './annotationProvider'; diff --git a/src/annotations/gutterHeatmapBlameAnnotationProvider.ts b/src/annotations/gutterHeatmapBlameAnnotationProvider.ts index b8c0dd0..38e0619 100644 --- a/src/annotations/gutterHeatmapBlameAnnotationProvider.ts +++ b/src/annotations/gutterHeatmapBlameAnnotationProvider.ts @@ -1,10 +1,10 @@ import type { TextEditor, TextEditorDecorationType } from 'vscode'; import { Range } from 'vscode'; -import { FileAnnotationType } from '../configuration'; +import { FileAnnotationType } from '../config'; import type { Container } from '../container'; import type { GitCommit } from '../git/models/commit'; -import { getLogScope } from '../logScope'; import { log } from '../system/decorators/log'; +import { getLogScope } from '../system/logger.scope'; import { Stopwatch } from '../system/stopwatch'; import type { GitDocumentState } from '../trackers/gitDocumentTracker'; import type { TrackedDocument } from '../trackers/trackedDocument'; diff --git a/src/annotations/lineAnnotationController.ts b/src/annotations/lineAnnotationController.ts index 5f2ef45..5a8be14 100644 --- a/src/annotations/lineAnnotationController.ts +++ b/src/annotations/lineAnnotationController.ts @@ -6,18 +6,18 @@ import type { TextEditorDecorationType, } from 'vscode'; import { CancellationTokenSource, DecorationRangeBehavior, Disposable, Range, window } from 'vscode'; -import { configuration } from '../configuration'; import { GlyphChars } from '../constants'; import type { Container } from '../container'; import { CommitFormatter } from '../git/formatters/commitFormatter'; import type { GitCommit } from '../git/models/commit'; import type { PullRequest } from '../git/models/pullRequest'; -import { Logger } from '../logger'; -import type { LogScope } from '../logScope'; -import { getLogScope } from '../logScope'; +import { configuration } from '../system/configuration'; import { debug, log } from '../system/decorators/log'; import { once } from '../system/event'; import { count, every, filter } from '../system/iterable'; +import { Logger } from '../system/logger'; +import type { LogScope } from '../system/logger.scope'; +import { getLogScope } from '../system/logger.scope'; import type { PromiseCancelledErrorWithId } from '../system/promise'; import { PromiseCancelledError, raceAll } from '../system/promise'; import { isTextEditor } from '../system/utils'; diff --git a/src/api/actionRunners.ts b/src/api/actionRunners.ts index a092afa..96d3066 100644 --- a/src/api/actionRunners.ts +++ b/src/api/actionRunners.ts @@ -1,11 +1,11 @@ import type { Event, QuickPickItem } from 'vscode'; import { Disposable, EventEmitter, window } from 'vscode'; -import type { Config } from '../configuration'; -import { configuration } from '../configuration'; +import type { Config } from '../config'; import { Commands, ContextKeys } from '../constants'; import type { Container } from '../container'; import { setContext } from '../context'; import { registerCommand } from '../system/command'; +import { configuration } from '../system/configuration'; import { sortCompare } from '../system/string'; import { getQuickPickIgnoreFocusOut } from '../system/utils'; import type { Action, ActionContext, ActionRunner } from './gitlens'; diff --git a/src/avatars.ts b/src/avatars.ts index 68ea40f..a33c365 100644 --- a/src/avatars.ts +++ b/src/avatars.ts @@ -1,12 +1,12 @@ import { EventEmitter, Uri } from 'vscode'; import { md5 } from '@env/crypto'; import { GravatarDefaultStyle } from './config'; -import { configuration } from './configuration'; import { ContextKeys } from './constants'; import { Container } from './container'; import { getContext } from './context'; import { getGitHubNoReplyAddressParts } from './git/remotes/github'; import type { StoredAvatar } from './storage'; +import { configuration } from './system/configuration'; import { debounce } from './system/function'; import { filterMap } from './system/iterable'; import { base64, equalsIgnoreCase } from './system/string'; diff --git a/src/codelens/codeLensController.ts b/src/codelens/codeLensController.ts index 495bacb..c962a5b 100644 --- a/src/codelens/codeLensController.ts +++ b/src/codelens/codeLensController.ts @@ -1,11 +1,11 @@ import type { ConfigurationChangeEvent } from 'vscode'; import { Disposable, languages } from 'vscode'; -import { configuration } from '../configuration'; import { ContextKeys } from '../constants'; import type { Container } from '../container'; import { setContext } from '../context'; -import { Logger } from '../logger'; +import { configuration } from '../system/configuration'; import { once } from '../system/event'; +import { Logger } from '../system/logger'; import type { DocumentBlameStateChangeEvent, DocumentDirtyIdleTriggerEvent, diff --git a/src/codelens/codeLensProvider.ts b/src/codelens/codeLensProvider.ts index aac7e10..579326e 100644 --- a/src/codelens/codeLensProvider.ts +++ b/src/codelens/codeLensProvider.ts @@ -18,18 +18,19 @@ import type { ShowQuickFileHistoryCommandArgs, ToggleFileChangesAnnotationCommandArgs, } from '../commands'; -import type { CodeLensConfig, CodeLensLanguageScope } from '../configuration'; -import { CodeLensCommand, CodeLensScopes, configuration, FileAnnotationType } from '../configuration'; +import type { CodeLensConfig, CodeLensLanguageScope } from '../config'; +import { CodeLensCommand, CodeLensScopes, FileAnnotationType } from '../config'; import { Commands, CoreCommands, Schemes } from '../constants'; import type { Container } from '../container'; import type { GitUri } from '../git/gitUri'; import type { GitBlame, GitBlameLines } from '../git/models/blame'; import type { GitCommit } from '../git/models/commit'; import { RemoteResourceType } from '../git/models/remoteResource'; -import { Logger } from '../logger'; import { asCommand, executeCoreCommand } from '../system/command'; +import { configuration } from '../system/configuration'; import { is, once } from '../system/function'; import { filterMap, find, first, join, map } from '../system/iterable'; +import { Logger } from '../system/logger'; import { isVirtualUri } from '../system/utils'; export class GitRecentChangeCodeLens extends CodeLens { diff --git a/src/commands/browseRepoAtRevision.ts b/src/commands/browseRepoAtRevision.ts index b995b86..b2d2994 100644 --- a/src/commands/browseRepoAtRevision.ts +++ b/src/commands/browseRepoAtRevision.ts @@ -2,9 +2,9 @@ import type { TextEditor, Uri } from 'vscode'; import { Commands, CoreCommands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { command, executeCoreCommand } from '../system/command'; +import { Logger } from '../system/logger'; import { basename } from '../system/path'; import { openWorkspace, OpenWorkspaceLocation } from '../system/utils'; import type { CommandContext } from './base'; diff --git a/src/commands/closeUnchangedFiles.ts b/src/commands/closeUnchangedFiles.ts index b1663d2..b37adff 100644 --- a/src/commands/closeUnchangedFiles.ts +++ b/src/commands/closeUnchangedFiles.ts @@ -1,12 +1,12 @@ import type { Uri } from 'vscode'; import { TabInputCustom, TabInputNotebook, TabInputNotebookDiff, TabInputText, TabInputTextDiff, window } from 'vscode'; -import { UriComparer } from '../comparers'; import { Commands } from '../constants'; import type { Container } from '../container'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { getRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; import { command } from '../system/command'; +import { UriComparer } from '../system/comparers'; +import { Logger } from '../system/logger'; import { Command } from './base'; export interface CloseUnchangedFilesCommandArgs { diff --git a/src/commands/compareWith.ts b/src/commands/compareWith.ts index b28d6a6..5168cba 100644 --- a/src/commands/compareWith.ts +++ b/src/commands/compareWith.ts @@ -1,10 +1,10 @@ import type { TextEditor, Uri } from 'vscode'; import { Commands } from '../constants'; import type { Container } from '../container'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; import { command } from '../system/command'; +import { Logger } from '../system/logger'; import type { CommandContext } from './base'; import { ActiveEditorCommand, getCommandUri } from './base'; diff --git a/src/commands/copyCurrentBranch.ts b/src/commands/copyCurrentBranch.ts index 567f366..c4f8a39 100644 --- a/src/commands/copyCurrentBranch.ts +++ b/src/commands/copyCurrentBranch.ts @@ -3,10 +3,10 @@ import { env } from 'vscode'; import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; import { command } from '../system/command'; +import { Logger } from '../system/logger'; import { ActiveEditorCommand, getCommandUri } from './base'; @command() diff --git a/src/commands/copyDeepLink.ts b/src/commands/copyDeepLink.ts index f42d6c8..93b806f 100644 --- a/src/commands/copyDeepLink.ts +++ b/src/commands/copyDeepLink.ts @@ -4,11 +4,11 @@ import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { splitBranchNameAndRemote } from '../git/models/branch'; import type { GitReference } from '../git/models/reference'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { showRemotePicker } from '../quickpicks/remotePicker'; import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; import { command } from '../system/command'; +import { Logger } from '../system/logger'; import { DeepLinkType, deepLinkTypeToString, refTypeToDeepLinkType } from '../uris/deepLinks/deepLink'; import type { CommandContext } from './base'; import { diff --git a/src/commands/copyMessageToClipboard.ts b/src/commands/copyMessageToClipboard.ts index 3246516..7b83050 100644 --- a/src/commands/copyMessageToClipboard.ts +++ b/src/commands/copyMessageToClipboard.ts @@ -4,10 +4,10 @@ import { Commands } from '../constants'; import type { Container } from '../container'; import { copyMessageToClipboard } from '../git/actions/commit'; import { GitUri } from '../git/gitUri'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { command } from '../system/command'; import { first } from '../system/iterable'; +import { Logger } from '../system/logger'; import type { CommandContext } from './base'; import { ActiveEditorCommand, diff --git a/src/commands/copyShaToClipboard.ts b/src/commands/copyShaToClipboard.ts index 33e6b0f..d415a15 100644 --- a/src/commands/copyShaToClipboard.ts +++ b/src/commands/copyShaToClipboard.ts @@ -1,14 +1,14 @@ import type { TextEditor, Uri } from 'vscode'; import { env } from 'vscode'; -import { configuration } from '../configuration'; import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { shortenRevision } from '../git/models/reference'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { command } from '../system/command'; +import { configuration } from '../system/configuration'; import { first } from '../system/iterable'; +import { Logger } from '../system/logger'; import type { CommandContext } from './base'; import { ActiveEditorCommand, diff --git a/src/commands/diffLineWithPrevious.ts b/src/commands/diffLineWithPrevious.ts index ecbe694..e47082f 100644 --- a/src/commands/diffLineWithPrevious.ts +++ b/src/commands/diffLineWithPrevious.ts @@ -3,9 +3,9 @@ import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import type { GitCommit } from '../git/models/commit'; -import { Logger } from '../logger'; import { showCommitHasNoPreviousCommitWarningMessage, showGenericErrorMessage } from '../messages'; import { command, executeCommand } from '../system/command'; +import { Logger } from '../system/logger'; import { ActiveEditorCommand, getCommandUri } from './base'; import type { DiffWithCommandArgs } from './diffWith'; diff --git a/src/commands/diffLineWithWorking.ts b/src/commands/diffLineWithWorking.ts index 1ed5bd1..995b385 100644 --- a/src/commands/diffLineWithWorking.ts +++ b/src/commands/diffLineWithWorking.ts @@ -5,9 +5,9 @@ import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import type { GitCommit } from '../git/models/commit'; import { uncommittedStaged } from '../git/models/constants'; -import { Logger } from '../logger'; import { showFileNotUnderSourceControlWarningMessage, showGenericErrorMessage } from '../messages'; import { command, executeCommand } from '../system/command'; +import { Logger } from '../system/logger'; import { ActiveEditorCommand, getCommandUri } from './base'; import type { DiffWithCommandArgs } from './diffWith'; diff --git a/src/commands/diffWith.ts b/src/commands/diffWith.ts index 0947522..6bfbd48 100644 --- a/src/commands/diffWith.ts +++ b/src/commands/diffWith.ts @@ -6,9 +6,9 @@ import type { GitCommit } from '../git/models/commit'; import { isCommit } from '../git/models/commit'; import { deletedOrMissing } from '../git/models/constants'; import { isShaLike, isUncommitted, shortenRevision } from '../git/models/reference'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { command, executeCoreCommand } from '../system/command'; +import { Logger } from '../system/logger'; import { basename } from '../system/path'; import { Command } from './base'; diff --git a/src/commands/diffWithNext.ts b/src/commands/diffWithNext.ts index f6c2cf7..deb2dc9 100644 --- a/src/commands/diffWithNext.ts +++ b/src/commands/diffWithNext.ts @@ -3,9 +3,9 @@ import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import type { GitCommit } from '../git/models/commit'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { command, executeCommand } from '../system/command'; +import { Logger } from '../system/logger'; import type { CommandContext } from './base'; import { ActiveEditorCommand, getCommandUri } from './base'; import type { DiffWithCommandArgs } from './diffWith'; diff --git a/src/commands/diffWithPrevious.ts b/src/commands/diffWithPrevious.ts index 3087be0..5fc7667 100644 --- a/src/commands/diffWithPrevious.ts +++ b/src/commands/diffWithPrevious.ts @@ -4,9 +4,9 @@ import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import type { GitCommit } from '../git/models/commit'; import { deletedOrMissing } from '../git/models/constants'; -import { Logger } from '../logger'; import { showCommitHasNoPreviousCommitWarningMessage, showGenericErrorMessage } from '../messages'; import { command, executeCommand } from '../system/command'; +import { Logger } from '../system/logger'; import { findOrOpenEditor } from '../system/utils'; import type { CommandContext } from './base'; import { ActiveEditorCommand, getCommandUri } from './base'; diff --git a/src/commands/diffWithRevision.ts b/src/commands/diffWithRevision.ts index 41570b4..80c51a9 100644 --- a/src/commands/diffWithRevision.ts +++ b/src/commands/diffWithRevision.ts @@ -3,11 +3,11 @@ import { Commands, GlyphChars, quickPickTitleMaxChars } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { shortenRevision } from '../git/models/reference'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { showCommitPicker } from '../quickpicks/commitPicker'; import { CommandQuickPickItem } from '../quickpicks/items/common'; import { command, executeCommand } from '../system/command'; +import { Logger } from '../system/logger'; import { pad } from '../system/string'; import { ActiveEditorCommand, getCommandUri } from './base'; import type { DiffWithCommandArgs } from './diffWith'; diff --git a/src/commands/diffWithWorking.ts b/src/commands/diffWithWorking.ts index 9c36cd8..a0cb6fc 100644 --- a/src/commands/diffWithWorking.ts +++ b/src/commands/diffWithWorking.ts @@ -4,9 +4,9 @@ import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { deletedOrMissing, uncommittedStaged } from '../git/models/constants'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { command, executeCommand } from '../system/command'; +import { Logger } from '../system/logger'; import { ActiveEditorCommand, getCommandUri } from './base'; import type { DiffWithCommandArgs } from './diffWith'; diff --git a/src/commands/externalDiff.ts b/src/commands/externalDiff.ts index b357da2..03054d5 100644 --- a/src/commands/externalDiff.ts +++ b/src/commands/externalDiff.ts @@ -2,16 +2,16 @@ import type { SourceControlResourceState } from 'vscode'; import { env, Uri, window } from 'vscode'; import type { ScmResource } from '../@types/vscode.git.resources'; import { ScmResourceGroupType, ScmStatus } from '../@types/vscode.git.resources.enums'; -import { configuration } from '../configuration'; import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { isUncommitted } from '../git/models/reference'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { getRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; import { filterMap } from '../system/array'; import { command } from '../system/command'; +import { configuration } from '../system/configuration'; +import { Logger } from '../system/logger'; import type { CommandContext } from './base'; import { Command, isCommandContextViewNodeHasFileCommit, isCommandContextViewNodeHasFileRefs } from './base'; diff --git a/src/commands/ghpr/openOrCreateWorktree.ts b/src/commands/ghpr/openOrCreateWorktree.ts index 54b1a3e..a578d9b 100644 --- a/src/commands/ghpr/openOrCreateWorktree.ts +++ b/src/commands/ghpr/openOrCreateWorktree.ts @@ -7,8 +7,8 @@ import { create as createWorktree, open as openWorktree } from '../../git/action import { createReference } from '../../git/models/reference'; import type { GitRemote } from '../../git/models/remote'; import { parseGitRemoteUrl } from '../../git/parsers/remoteParser'; -import { Logger } from '../../logger'; import { command } from '../../system/command'; +import { Logger } from '../../system/logger'; import { waitUntilNextTick } from '../../system/promise'; import { Command } from '../base'; diff --git a/src/commands/git/push.ts b/src/commands/git/push.ts index 1f44bea..0f47514 100644 --- a/src/commands/git/push.ts +++ b/src/commands/git/push.ts @@ -1,4 +1,3 @@ -import { configuration } from '../../configuration'; import { CoreGitConfiguration, GlyphChars } from '../../constants'; import type { Container } from '../../container'; import { getRemoteNameFromBranchName } from '../../git/models/branch'; @@ -9,6 +8,7 @@ import { createDirectiveQuickPickItem, Directive } from '../../quickpicks/items/ import type { FlagsQuickPickItem } from '../../quickpicks/items/flags'; import { createFlagsQuickPickItem } from '../../quickpicks/items/flags'; import { isStringArray } from '../../system/array'; +import { configuration } from '../../system/configuration'; import { fromNow } from '../../system/date'; import { pad, pluralize } from '../../system/string'; import type { ViewsWithRepositoryFolders } from '../../views/viewBase'; diff --git a/src/commands/git/remote.ts b/src/commands/git/remote.ts index 5331298..a61127f 100644 --- a/src/commands/git/remote.ts +++ b/src/commands/git/remote.ts @@ -4,11 +4,11 @@ import type { Container } from '../../container'; import { reveal } from '../../git/actions/remote'; import type { GitRemote } from '../../git/models/remote'; import { Repository } from '../../git/models/repository'; -import { Logger } from '../../logger'; import { showGenericErrorMessage } from '../../messages'; import type { QuickPickItemOfT } from '../../quickpicks/items/common'; import type { FlagsQuickPickItem } from '../../quickpicks/items/flags'; import { createFlagsQuickPickItem } from '../../quickpicks/items/flags'; +import { Logger } from '../../system/logger'; import type { ViewsWithRepositoryFolders } from '../../views/viewBase'; import type { AsyncStepResultGenerator, diff --git a/src/commands/git/search.ts b/src/commands/git/search.ts index ac1fcfc..dc0b8d0 100644 --- a/src/commands/git/search.ts +++ b/src/commands/git/search.ts @@ -1,4 +1,3 @@ -import { configuration } from '../../configuration'; import { ContextKeys, GlyphChars } from '../../constants'; import type { Container } from '../../container'; import { getContext } from '../../context'; @@ -10,6 +9,7 @@ import type { SearchOperators, SearchQuery } from '../../git/search'; import { getSearchQueryComparisonKey, parseSearchQuery, searchOperators } from '../../git/search'; import type { QuickPickItemOfT } from '../../quickpicks/items/common'; import { ActionQuickPickItem } from '../../quickpicks/items/common'; +import { configuration } from '../../system/configuration'; import { pluralize } from '../../system/string'; import { SearchResultsNode } from '../../views/nodes/searchResultsNode'; import type { ViewsWithRepositoryFolders } from '../../views/viewBase'; diff --git a/src/commands/git/stash.ts b/src/commands/git/stash.ts index 3b2a795..7fccd2b 100644 --- a/src/commands/git/stash.ts +++ b/src/commands/git/stash.ts @@ -9,12 +9,12 @@ import type { GitStashCommit } from '../../git/models/commit'; import type { GitStashReference } from '../../git/models/reference'; import { getReferenceLabel } from '../../git/models/reference'; import type { Repository } from '../../git/models/repository'; -import { Logger } from '../../logger'; import { showGenericErrorMessage } from '../../messages'; import type { QuickPickItemOfT } from '../../quickpicks/items/common'; import type { FlagsQuickPickItem } from '../../quickpicks/items/flags'; import { createFlagsQuickPickItem } from '../../quickpicks/items/flags'; import { formatPath } from '../../system/formatPath'; +import { Logger } from '../../system/logger'; import { pad } from '../../system/string'; import type { ViewsWithRepositoryFolders } from '../../views/viewBase'; import { getSteps } from '../gitCommands.utils'; diff --git a/src/commands/git/worktree.ts b/src/commands/git/worktree.ts index 355c0ce..893662d 100644 --- a/src/commands/git/worktree.ts +++ b/src/commands/git/worktree.ts @@ -1,7 +1,6 @@ import type { MessageItem } from 'vscode'; import { QuickInputButtons, Uri, window, workspace } from 'vscode'; -import type { Config } from '../../configuration'; -import { configuration } from '../../configuration'; +import type { Config } from '../../config'; import type { Container } from '../../container'; import { PlusFeatures } from '../../features'; import { convertOpenFlagsToLocation, reveal, revealInFileExplorer } from '../../git/actions/worktree'; @@ -21,6 +20,7 @@ import { createQuickPickSeparator } from '../../quickpicks/items/common'; import { Directive } from '../../quickpicks/items/directive'; import type { FlagsQuickPickItem } from '../../quickpicks/items/flags'; import { createFlagsQuickPickItem } from '../../quickpicks/items/flags'; +import { configuration } from '../../system/configuration'; import { basename, isDescendent } from '../../system/path'; import { pluralize, truncateLeft } from '../../system/string'; import { openWorkspace, OpenWorkspaceLocation } from '../../system/utils'; diff --git a/src/commands/gitCommands.ts b/src/commands/gitCommands.ts index 8a38423..28c1c16 100644 --- a/src/commands/gitCommands.ts +++ b/src/commands/gitCommands.ts @@ -1,12 +1,12 @@ import type { Disposable, InputBox, QuickInputButton, QuickPick, QuickPickItem } from 'vscode'; import { InputBoxValidationSeverity, QuickInputButtons, window } from 'vscode'; -import { configuration } from '../configuration'; import { Commands } from '../constants'; import { Container } from '../container'; -import type { KeyMapping } from '../keyboard'; import { Directive, isDirective, isDirectiveQuickPickItem } from '../quickpicks/items/directive'; import { command } from '../system/command'; +import { configuration } from '../system/configuration'; import { log } from '../system/decorators/log'; +import type { KeyMapping } from '../system/keyboard'; import type { Deferred } from '../system/promise'; import { isPromise } from '../system/promise'; import type { CommandContext } from './base'; diff --git a/src/commands/gitCommands.utils.ts b/src/commands/gitCommands.utils.ts index 5cf610a..36f7e8a 100644 --- a/src/commands/gitCommands.utils.ts +++ b/src/commands/gitCommands.utils.ts @@ -1,9 +1,9 @@ import { GitCommandSorting } from '../config'; -import { configuration } from '../configuration'; import { ContextKeys } from '../constants'; import type { Container } from '../container'; import { getContext } from '../context'; import type { RecentUsage } from '../storage'; +import { configuration } from '../system/configuration'; import { BranchGitCommand } from './git/branch'; import { CherryPickGitCommand } from './git/cherry-pick'; import { CoAuthorsGitCommand } from './git/coauthors'; diff --git a/src/commands/logging.ts b/src/commands/logging.ts index 3ec8fe1..7295620 100644 --- a/src/commands/logging.ts +++ b/src/commands/logging.ts @@ -1,7 +1,8 @@ -import { configuration, OutputLevel } from '../configuration'; +import { OutputLevel } from '../config'; import { Commands } from '../constants'; import type { Container } from '../container'; import { command } from '../system/command'; +import { configuration } from '../system/configuration'; import { Command } from './base'; @command() diff --git a/src/commands/openAssociatedPullRequestOnRemote.ts b/src/commands/openAssociatedPullRequestOnRemote.ts index 431f53f..2a11ed3 100644 --- a/src/commands/openAssociatedPullRequestOnRemote.ts +++ b/src/commands/openAssociatedPullRequestOnRemote.ts @@ -2,8 +2,8 @@ import type { TextEditor, Uri } from 'vscode'; import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; -import { Logger } from '../logger'; import { command, executeCommand } from '../system/command'; +import { Logger } from '../system/logger'; import { ActiveEditorCommand, getCommandUri } from './base'; import type { OpenPullRequestOnRemoteCommandArgs } from './openPullRequestOnRemote'; diff --git a/src/commands/openBranchOnRemote.ts b/src/commands/openBranchOnRemote.ts index fdd9f94..a1b7937 100644 --- a/src/commands/openBranchOnRemote.ts +++ b/src/commands/openBranchOnRemote.ts @@ -3,12 +3,12 @@ import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { RemoteResourceType } from '../git/models/remoteResource'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { CommandQuickPickItem } from '../quickpicks/items/common'; import { ReferencesQuickPickIncludes, showReferencePicker } from '../quickpicks/referencePicker'; import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; import { command, executeCommand } from '../system/command'; +import { Logger } from '../system/logger'; import type { CommandContext } from './base'; import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasBranch } from './base'; import type { OpenOnRemoteCommandArgs } from './openOnRemote'; diff --git a/src/commands/openBranchesOnRemote.ts b/src/commands/openBranchesOnRemote.ts index 27e8f87..a9c43aa 100644 --- a/src/commands/openBranchesOnRemote.ts +++ b/src/commands/openBranchesOnRemote.ts @@ -3,10 +3,10 @@ import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { RemoteResourceType } from '../git/models/remoteResource'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; import { command, executeCommand } from '../system/command'; +import { Logger } from '../system/logger'; import type { CommandContext } from './base'; import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasRemote } from './base'; import type { OpenOnRemoteCommandArgs } from './openOnRemote'; diff --git a/src/commands/openChangedFiles.ts b/src/commands/openChangedFiles.ts index 2f73415..d2713cc 100644 --- a/src/commands/openChangedFiles.ts +++ b/src/commands/openChangedFiles.ts @@ -2,11 +2,11 @@ import type { Uri } from 'vscode'; import { window } from 'vscode'; import { Commands } from '../constants'; import type { Container } from '../container'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { getRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; import { filterMap } from '../system/array'; import { command } from '../system/command'; +import { Logger } from '../system/logger'; import { findOrOpenEditors } from '../system/utils'; import { Command } from './base'; diff --git a/src/commands/openCommitOnRemote.ts b/src/commands/openCommitOnRemote.ts index 246a015..0051569 100644 --- a/src/commands/openCommitOnRemote.ts +++ b/src/commands/openCommitOnRemote.ts @@ -4,10 +4,10 @@ import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { deletedOrMissing } from '../git/models/constants'; import { RemoteResourceType } from '../git/models/remoteResource'; -import { Logger } from '../logger'; import { showFileNotUnderSourceControlWarningMessage, showGenericErrorMessage } from '../messages'; import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; import { command, executeCommand } from '../system/command'; +import { Logger } from '../system/logger'; import type { CommandContext } from './base'; import { ActiveEditorCommand, diff --git a/src/commands/openComparisonOnRemote.ts b/src/commands/openComparisonOnRemote.ts index e83e7d7..00c4ca4 100644 --- a/src/commands/openComparisonOnRemote.ts +++ b/src/commands/openComparisonOnRemote.ts @@ -1,9 +1,9 @@ import { Commands } from '../constants'; import type { Container } from '../container'; import { RemoteResourceType } from '../git/models/remoteResource'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { command, executeCommand } from '../system/command'; +import { Logger } from '../system/logger'; import { ResultsCommitsNode } from '../views/nodes/resultsCommitsNode'; import type { CommandContext } from './base'; import { Command } from './base'; diff --git a/src/commands/openCurrentBranchOnRemote.ts b/src/commands/openCurrentBranchOnRemote.ts index c630161..9c68794 100644 --- a/src/commands/openCurrentBranchOnRemote.ts +++ b/src/commands/openCurrentBranchOnRemote.ts @@ -3,10 +3,10 @@ import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { RemoteResourceType } from '../git/models/remoteResource'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; import { command, executeCommand } from '../system/command'; +import { Logger } from '../system/logger'; import { ActiveEditorCommand, getCommandUri } from './base'; import type { OpenOnRemoteCommandArgs } from './openOnRemote'; diff --git a/src/commands/openDirectoryCompare.ts b/src/commands/openDirectoryCompare.ts index 3d27568..2b4662e 100644 --- a/src/commands/openDirectoryCompare.ts +++ b/src/commands/openDirectoryCompare.ts @@ -2,11 +2,11 @@ import type { TextEditor, Uri } from 'vscode'; import { Commands } from '../constants'; import type { Container } from '../container'; import { openDirectoryCompare } from '../git/actions/commit'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { showReferencePicker } from '../quickpicks/referencePicker'; import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; import { command } from '../system/command'; +import { Logger } from '../system/logger'; import { CompareResultsNode } from '../views/nodes/compareResultsNode'; import type { CommandContext } from './base'; import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasRef } from './base'; diff --git a/src/commands/openFileAtRevision.ts b/src/commands/openFileAtRevision.ts index cc2ca1c..4efe34d 100644 --- a/src/commands/openFileAtRevision.ts +++ b/src/commands/openFileAtRevision.ts @@ -1,16 +1,16 @@ import type { TextDocumentShowOptions, TextEditor } from 'vscode'; import { Uri } from 'vscode'; -import { FileAnnotationType } from '../configuration'; +import { FileAnnotationType } from '../config'; import { Commands, GlyphChars, quickPickTitleMaxChars } from '../constants'; import type { Container } from '../container'; import { openFileAtRevision } from '../git/actions/commit'; import { GitUri } from '../git/gitUri'; import { shortenRevision } from '../git/models/reference'; -import { Logger } from '../logger'; import { showCommitHasNoPreviousCommitWarningMessage, showGenericErrorMessage } from '../messages'; import { showCommitPicker } from '../quickpicks/commitPicker'; import { CommandQuickPickItem } from '../quickpicks/items/common'; import { command } from '../system/command'; +import { Logger } from '../system/logger'; import { pad } from '../system/string'; import type { CommandContext } from './base'; import { ActiveEditorCommand, getCommandUri } from './base'; diff --git a/src/commands/openFileAtRevisionFrom.ts b/src/commands/openFileAtRevisionFrom.ts index da4f94c..563ac4b 100644 --- a/src/commands/openFileAtRevisionFrom.ts +++ b/src/commands/openFileAtRevisionFrom.ts @@ -1,5 +1,5 @@ import type { TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; -import type { FileAnnotationType } from '../configuration'; +import type { FileAnnotationType } from '../config'; import { Commands, GlyphChars, quickPickTitleMaxChars } from '../constants'; import type { Container } from '../container'; import { openFileAtRevision } from '../git/actions/commit'; diff --git a/src/commands/openFileOnRemote.ts b/src/commands/openFileOnRemote.ts index d3c5d76..9fcb329 100644 --- a/src/commands/openFileOnRemote.ts +++ b/src/commands/openFileOnRemote.ts @@ -1,17 +1,17 @@ import type { TextEditor, Uri } from 'vscode'; import { Range } from 'vscode'; -import { UriComparer } from '../comparers'; -import { BranchSorting, TagSorting } from '../configuration'; +import { BranchSorting, TagSorting } from '../config'; import { Commands, GlyphChars } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { getBranchNameWithoutRemote, getRemoteNameFromBranchName } from '../git/models/branch'; import { isSha } from '../git/models/reference'; import { RemoteResourceType } from '../git/models/remoteResource'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { showReferencePicker } from '../quickpicks/referencePicker'; import { command, executeCommand } from '../system/command'; +import { UriComparer } from '../system/comparers'; +import { Logger } from '../system/logger'; import { pad, splitSingle } from '../system/string'; import { StatusFileNode } from '../views/nodes/statusFileNode'; import type { CommandContext } from './base'; diff --git a/src/commands/openOnRemote.ts b/src/commands/openOnRemote.ts index e25c2da..f62a22f 100644 --- a/src/commands/openOnRemote.ts +++ b/src/commands/openOnRemote.ts @@ -5,10 +5,10 @@ import { GitRemote } from '../git/models/remote'; import type { RemoteResource } from '../git/models/remoteResource'; import { RemoteResourceType } from '../git/models/remoteResource'; import type { RemoteProvider } from '../git/remotes/remoteProvider'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { showRemoteProviderPicker } from '../quickpicks/remoteProviderPicker'; import { command } from '../system/command'; +import { Logger } from '../system/logger'; import { pad, splitSingle } from '../system/string'; import { Command } from './base'; diff --git a/src/commands/openRepoOnRemote.ts b/src/commands/openRepoOnRemote.ts index a5cac83..b8801b6 100644 --- a/src/commands/openRepoOnRemote.ts +++ b/src/commands/openRepoOnRemote.ts @@ -3,10 +3,10 @@ import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { RemoteResourceType } from '../git/models/remoteResource'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; import { command, executeCommand } from '../system/command'; +import { Logger } from '../system/logger'; import type { CommandContext } from './base'; import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasRemote } from './base'; import type { OpenOnRemoteCommandArgs } from './openOnRemote'; diff --git a/src/commands/openRevisionFile.ts b/src/commands/openRevisionFile.ts index b1698b5..1bfa1c5 100644 --- a/src/commands/openRevisionFile.ts +++ b/src/commands/openRevisionFile.ts @@ -1,13 +1,13 @@ import type { TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; -import type { FileAnnotationType } from '../configuration'; +import type { FileAnnotationType } from '../config'; import { Commands } from '../constants'; import type { Container } from '../container'; import { openFileAtRevision } from '../git/actions/commit'; import { GitUri } from '../git/gitUri'; import { deletedOrMissing } from '../git/models/constants'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { command } from '../system/command'; +import { Logger } from '../system/logger'; import { ActiveEditorCommand, getCommandUri } from './base'; export interface OpenRevisionFileCommandArgs { diff --git a/src/commands/openWorkingFile.ts b/src/commands/openWorkingFile.ts index 8231c00..4c72b89 100644 --- a/src/commands/openWorkingFile.ts +++ b/src/commands/openWorkingFile.ts @@ -1,12 +1,12 @@ import type { TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; import { Range, window } from 'vscode'; -import type { FileAnnotationType } from '../configuration'; +import type { FileAnnotationType } from '../config'; import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri, isGitUri } from '../git/gitUri'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { command } from '../system/command'; +import { Logger } from '../system/logger'; import { findOrOpenEditor } from '../system/utils'; import { ActiveEditorCommand, getCommandUri } from './base'; diff --git a/src/commands/quickCommand.steps.ts b/src/commands/quickCommand.steps.ts index 3f78ca4..fc1ae1e 100644 --- a/src/commands/quickCommand.steps.ts +++ b/src/commands/quickCommand.steps.ts @@ -1,5 +1,5 @@ import type { QuickInputButton, QuickPick } from 'vscode'; -import { BranchSorting, configuration, TagSorting } from '../configuration'; +import { BranchSorting, TagSorting } from '../config'; import { Commands, GlyphChars, quickPickTitleMaxChars } from '../constants'; import { Container } from '../container'; import type { PlusFeatures } from '../features'; @@ -94,6 +94,7 @@ import { } from '../quickpicks/remoteProviderPicker'; import { isSubscriptionPaidPlan, isSubscriptionPreviewTrialExpired } from '../subscription'; import { filterMap, intersection, isStringArray } from '../system/array'; +import { configuration } from '../system/configuration'; import { formatPath } from '../system/formatPath'; import { map } from '../system/iterable'; import { getSettledValue } from '../system/promise'; diff --git a/src/commands/quickCommand.ts b/src/commands/quickCommand.ts index 432eab8..82d7e39 100644 --- a/src/commands/quickCommand.ts +++ b/src/commands/quickCommand.ts @@ -1,9 +1,9 @@ import type { InputBox, QuickInputButton, QuickPick, QuickPickItem } from 'vscode'; -import { configuration } from '../configuration'; import type { Container } from '../container'; -import type { Keys } from '../keyboard'; import type { DirectiveQuickPickItem } from '../quickpicks/items/directive'; import { createDirectiveQuickPickItem, Directive, isDirective } from '../quickpicks/items/directive'; +import { configuration } from '../system/configuration'; +import type { Keys } from '../system/keyboard'; export * from './quickCommand.buttons'; export * from './quickCommand.steps'; diff --git a/src/commands/resets.ts b/src/commands/resets.ts index 190e2e2..fce6233 100644 --- a/src/commands/resets.ts +++ b/src/commands/resets.ts @@ -1,9 +1,9 @@ import { ConfigurationTarget } from 'vscode'; import { resetAvatarCache } from '../avatars'; -import { configuration } from '../configuration'; import { Commands } from '../constants'; import type { Container } from '../container'; import { command } from '../system/command'; +import { configuration } from '../system/configuration'; import { Command } from './base'; @command() diff --git a/src/commands/searchCommits.ts b/src/commands/searchCommits.ts index 093f379..ac64247 100644 --- a/src/commands/searchCommits.ts +++ b/src/commands/searchCommits.ts @@ -1,9 +1,9 @@ -import { configuration } from '../configuration'; import { Commands } from '../constants'; import type { Container } from '../container'; import { executeGitCommand } from '../git/actions'; import type { SearchQuery } from '../git/search'; import { command } from '../system/command'; +import { configuration } from '../system/configuration'; import { SearchResultsNode } from '../views/nodes/searchResultsNode'; import type { CommandContext } from './base'; import { Command, isCommandContextViewNodeHasRepository } from './base'; diff --git a/src/commands/setViewsLayout.ts b/src/commands/setViewsLayout.ts index 9206f09..6fcfd45 100644 --- a/src/commands/setViewsLayout.ts +++ b/src/commands/setViewsLayout.ts @@ -1,5 +1,5 @@ import { window } from 'vscode'; -import { viewsConfigKeys } from '../configuration'; +import { viewsConfigKeys } from '../config'; import { Commands, CoreCommands } from '../constants'; import type { Container } from '../container'; import { command, executeCommand, executeCoreCommand } from '../system/command'; diff --git a/src/commands/showCommitsInView.ts b/src/commands/showCommitsInView.ts index f9cdb62..562eb62 100644 --- a/src/commands/showCommitsInView.ts +++ b/src/commands/showCommitsInView.ts @@ -6,10 +6,10 @@ import { showDetailsView } from '../git/actions/commit'; import { GitUri } from '../git/gitUri'; import { createReference } from '../git/models/reference'; import { createSearchQueryForCommits } from '../git/search'; -import { Logger } from '../logger'; import { showFileNotUnderSourceControlWarningMessage, showGenericErrorMessage } from '../messages'; import { command } from '../system/command'; import { filterMap } from '../system/iterable'; +import { Logger } from '../system/logger'; import type { CommandContext } from './base'; import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasCommit } from './base'; diff --git a/src/commands/showLastQuickPick.ts b/src/commands/showLastQuickPick.ts index b02bbfa..5a3ce7b 100644 --- a/src/commands/showLastQuickPick.ts +++ b/src/commands/showLastQuickPick.ts @@ -1,9 +1,9 @@ import { commands } from 'vscode'; import { Commands } from '../constants'; import type { Container } from '../container'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { command } from '../system/command'; +import { Logger } from '../system/logger'; import { Command, getLastCommand } from './base'; @command() diff --git a/src/commands/showQuickCommit.ts b/src/commands/showQuickCommit.ts index 330f436..03faf86 100644 --- a/src/commands/showQuickCommit.ts +++ b/src/commands/showQuickCommit.ts @@ -6,7 +6,6 @@ import { reveal } from '../git/actions/commit'; import { GitUri } from '../git/gitUri'; import type { GitCommit, GitStashCommit } from '../git/models/commit'; import type { GitLog } from '../git/models/log'; -import { Logger } from '../logger'; import { showCommitNotFoundWarningMessage, showFileNotUnderSourceControlWarningMessage, @@ -14,6 +13,7 @@ import { showLineUncommittedWarningMessage, } from '../messages'; import { command } from '../system/command'; +import { Logger } from '../system/logger'; import type { CommandContext } from './base'; import { ActiveEditorCachedCommand, getCommandUri, isCommandContextViewNodeHasCommit } from './base'; diff --git a/src/commands/showQuickCommitFile.ts b/src/commands/showQuickCommitFile.ts index 3b1ffd3..9fcf8c5 100644 --- a/src/commands/showQuickCommitFile.ts +++ b/src/commands/showQuickCommitFile.ts @@ -7,7 +7,6 @@ import { GitUri } from '../git/gitUri'; import type { GitCommit, GitStashCommit } from '../git/models/commit'; import { isCommit } from '../git/models/commit'; import type { GitLog } from '../git/models/log'; -import { Logger } from '../logger'; import { showCommitNotFoundWarningMessage, showFileNotUnderSourceControlWarningMessage, @@ -15,6 +14,7 @@ import { showLineUncommittedWarningMessage, } from '../messages'; import { command } from '../system/command'; +import { Logger } from '../system/logger'; import type { CommandContext } from './base'; import { ActiveEditorCachedCommand, getCommandUri, isCommandContextViewNodeHasCommit } from './base'; diff --git a/src/commands/switchMode.ts b/src/commands/switchMode.ts index 7e9e2ce..181f700 100644 --- a/src/commands/switchMode.ts +++ b/src/commands/switchMode.ts @@ -1,11 +1,11 @@ import { ConfigurationTarget } from 'vscode'; -import { configuration } from '../configuration'; import { Commands } from '../constants'; import type { Container } from '../container'; -import { getLogScope } from '../logScope'; import { showModePicker } from '../quickpicks/modePicker'; import { command } from '../system/command'; +import { configuration } from '../system/configuration'; import { log } from '../system/decorators/log'; +import { getLogScope } from '../system/logger.scope'; import { Command } from './base'; @command() diff --git a/src/commands/toggleFileAnnotations.ts b/src/commands/toggleFileAnnotations.ts index 0c583b8..a6aaf86 100644 --- a/src/commands/toggleFileAnnotations.ts +++ b/src/commands/toggleFileAnnotations.ts @@ -2,13 +2,13 @@ import type { TextEditor, TextEditorEdit, Uri } from 'vscode'; import { window } from 'vscode'; import type { AnnotationContext } from '../annotations/annotationProvider'; import type { ChangesAnnotationContext } from '../annotations/gutterChangesAnnotationProvider'; -import { UriComparer } from '../comparers'; -import { FileAnnotationType } from '../configuration'; +import { FileAnnotationType } from '../config'; import { Commands } from '../constants'; import type { Container } from '../container'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { command } from '../system/command'; +import { UriComparer } from '../system/comparers'; +import { Logger } from '../system/logger'; import { isTextEditor } from '../system/utils'; import { ActiveEditorCommand, EditorCommand } from './base'; diff --git a/src/commands/toggleLineBlame.ts b/src/commands/toggleLineBlame.ts index c7c80ef..eb6a747 100644 --- a/src/commands/toggleLineBlame.ts +++ b/src/commands/toggleLineBlame.ts @@ -1,9 +1,9 @@ import type { TextEditor, Uri } from 'vscode'; import { Commands } from '../constants'; import type { Container } from '../container'; -import { Logger } from '../logger'; import { showGenericErrorMessage } from '../messages'; import { command } from '../system/command'; +import { Logger } from '../system/logger'; import { ActiveEditorCommand } from './base'; @command() diff --git a/src/comparers.ts b/src/comparers.ts deleted file mode 100644 index 407340b..0000000 --- a/src/comparers.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { TextEditor, Uri } from 'vscode'; - -abstract class Comparer { - abstract equals(lhs: T, rhs: T): boolean; -} - -class UriComparer extends Comparer { - equals(lhs: Uri | undefined, rhs: Uri | undefined, options: { exact?: boolean } = { exact: false }) { - if (lhs === rhs) return true; - if (lhs == null || rhs == null) return false; - - if (options.exact) { - return lhs.toString() === rhs.toString(); - } - return lhs.scheme === rhs.scheme && lhs.fsPath === rhs.fsPath; - } -} - -class TextEditorComparer extends Comparer { - equals( - lhs: TextEditor | undefined, - rhs: TextEditor | undefined, - options: { usePosition: boolean } = { usePosition: false }, - ) { - if (lhs === rhs) return true; - if (lhs == null || rhs == null) return false; - - if (options.usePosition && lhs.viewColumn !== rhs.viewColumn) return false; - - return lhs.document === rhs.document; - } -} - -const textEditorComparer = new TextEditorComparer(); -const uriComparer = new UriComparer(); -export { textEditorComparer as TextEditorComparer, uriComparer as UriComparer }; diff --git a/src/config.ts b/src/config.ts index d6a29d3..c7dc6eb 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,5 +1,5 @@ -import { LogLevel } from './constants'; import type { DateTimeFormat } from './system/date'; +import { LogLevel } from './system/logger.constants'; export interface Config { autolinks: AutolinkReference[] | null; diff --git a/src/configuration.ts b/src/configuration.ts deleted file mode 100644 index 17c0398..0000000 --- a/src/configuration.ts +++ /dev/null @@ -1,345 +0,0 @@ -export * from './config'; - -import type { ConfigurationChangeEvent, ConfigurationScope, Event, ExtensionContext } from 'vscode'; -import { ConfigurationTarget, EventEmitter, workspace } from 'vscode'; -import type { Config } from './config'; -import { areEqual } from './system/object'; - -const configPrefix = 'gitlens'; - -interface ConfigurationOverrides { - get(section: T, value: ConfigPathValue): ConfigPathValue; - getAll(config: Config): Config; - onChange(e: ConfigurationChangeEvent): ConfigurationChangeEvent; -} - -export class Configuration { - static configure(context: ExtensionContext): void { - context.subscriptions.push( - // eslint-disable-next-line @typescript-eslint/no-use-before-define - workspace.onDidChangeConfiguration(configuration.onConfigurationChanged, configuration), - ); - } - - private _onDidChange = new EventEmitter(); - get onDidChange(): Event { - return this._onDidChange.event; - } - - private _onDidChangeAny = new EventEmitter(); - get onDidChangeAny(): Event { - return this._onDidChangeAny.event; - } - - private _onWillChange = new EventEmitter(); - get onWillChange(): Event { - return this._onWillChange.event; - } - - private onConfigurationChanged(e: ConfigurationChangeEvent) { - if (!e.affectsConfiguration(configPrefix)) { - this._onDidChangeAny.fire(e); - - return; - } - - this._onWillChange.fire(e); - - if (this._overrides?.onChange != null) { - e = this._overrides.onChange(e); - } - - this._onDidChangeAny.fire(e); - this._onDidChange.fire(e); - } - - private _overrides: Partial | undefined; - - applyOverrides(overrides: ConfigurationOverrides): void { - this._overrides = overrides; - } - - clearOverrides(): void { - if (this._overrides == null) return; - - // Don't clear the "onChange" override as we need to keep it until the stack unwinds (so the the event propagates with the override) - this._overrides.get = undefined; - this._overrides.getAll = undefined; - queueMicrotask(() => (this._overrides = undefined)); - } - - get(section: T, scope?: ConfigurationScope | null): ConfigPathValue; - get( - section: T, - scope: ConfigurationScope | null | undefined, - defaultValue: NonNullable>, - ): NonNullable>; - get( - section: T, - scope?: ConfigurationScope | null, - defaultValue?: NonNullable>, - ): ConfigPathValue { - const value = - defaultValue === undefined - ? workspace.getConfiguration(configPrefix, scope).get>(section)! - : workspace.getConfiguration(configPrefix, scope).get>(section, defaultValue)!; - return this._overrides?.get == null ? value : this._overrides.get(section, value); - } - - getAll(skipOverrides?: boolean): Config { - const config = workspace.getConfiguration().get(configPrefix)!; - return skipOverrides || this._overrides?.getAll == null ? config : this._overrides.getAll(config); - } - - getAny(section: string, scope?: ConfigurationScope | null): T | undefined; - getAny(section: string, scope: ConfigurationScope | null | undefined, defaultValue: T): T; - getAny(section: string, scope?: ConfigurationScope | null, defaultValue?: T): T | undefined { - return defaultValue === undefined - ? workspace.getConfiguration(undefined, scope).get(section) - : workspace.getConfiguration(undefined, scope).get(section, defaultValue); - } - - changed( - e: ConfigurationChangeEvent | undefined, - section: T | T[], - scope?: ConfigurationScope | null | undefined, - ): boolean { - if (e == null) return true; - - return Array.isArray(section) - ? section.some(s => e.affectsConfiguration(`${configPrefix}.${s}`, scope!)) - : e.affectsConfiguration(`${configPrefix}.${section}`, scope!); - } - - inspect>(section: T, scope?: ConfigurationScope | null) { - return workspace - .getConfiguration(configPrefix, scope) - .inspect(section === undefined ? configPrefix : section); - } - - inspectAny(section: string, scope?: ConfigurationScope | null) { - return workspace.getConfiguration(undefined, scope).inspect(section); - } - - isUnset(section: T, scope?: ConfigurationScope | null): boolean { - const inspect = this.inspect(section, scope)!; - if (inspect.workspaceFolderValue !== undefined) return false; - if (inspect.workspaceValue !== undefined) return false; - if (inspect.globalValue !== undefined) return false; - - return true; - } - - async migrate( - from: string, - to: T, - options: { fallbackValue?: ConfigPathValue; migrationFn?(value: any): ConfigPathValue }, - ): Promise { - const inspection = this.inspect(from as any); - if (inspection === undefined) return false; - - let migrated = false; - if (inspection.globalValue !== undefined) { - await this.update( - to, - options.migrationFn != null ? options.migrationFn(inspection.globalValue) : inspection.globalValue, - ConfigurationTarget.Global, - ); - migrated = true; - // Can't delete the old setting currently because it errors with `Unable to write to User Settings because is not a registered configuration` - // if (from !== to) { - // try { - // await this.update(from, undefined, ConfigurationTarget.Global); - // } - // catch { } - // } - } - - if (inspection.workspaceValue !== undefined) { - await this.update( - to, - options.migrationFn != null - ? options.migrationFn(inspection.workspaceValue) - : inspection.workspaceValue, - ConfigurationTarget.Workspace, - ); - migrated = true; - // Can't delete the old setting currently because it errors with `Unable to write to User Settings because is not a registered configuration` - // if (from !== to) { - // try { - // await this.update(from, undefined, ConfigurationTarget.Workspace); - // } - // catch { } - // } - } - - if (inspection.workspaceFolderValue !== undefined) { - await this.update( - to, - options.migrationFn != null - ? options.migrationFn(inspection.workspaceFolderValue) - : inspection.workspaceFolderValue, - ConfigurationTarget.WorkspaceFolder, - ); - migrated = true; - // Can't delete the old setting currently because it errors with `Unable to write to User Settings because is not a registered configuration` - // if (from !== to) { - // try { - // await this.update(from, undefined, ConfigurationTarget.WorkspaceFolder); - // } - // catch { } - // } - } - - if (!migrated && options.fallbackValue !== undefined) { - await this.update(to, options.fallbackValue, ConfigurationTarget.Global); - migrated = true; - } - - return migrated; - } - - async migrateIfMissing( - from: string, - to: T, - options: { migrationFn?(value: any): ConfigPathValue }, - ): Promise { - const fromInspection = this.inspect(from as any); - if (fromInspection === undefined) return; - - const toInspection = this.inspect(to); - if (fromInspection.globalValue !== undefined) { - if (toInspection === undefined || toInspection.globalValue === undefined) { - await this.update( - to, - options.migrationFn != null - ? options.migrationFn(fromInspection.globalValue) - : fromInspection.globalValue, - ConfigurationTarget.Global, - ); - // Can't delete the old setting currently because it errors with `Unable to write to User Settings because is not a registered configuration` - // if (from !== to) { - // try { - // await this.update(from, undefined, ConfigurationTarget.Global); - // } - // catch { } - // } - } - } - - if (fromInspection.workspaceValue !== undefined) { - if (toInspection === undefined || toInspection.workspaceValue === undefined) { - await this.update( - to, - options.migrationFn != null - ? options.migrationFn(fromInspection.workspaceValue) - : fromInspection.workspaceValue, - ConfigurationTarget.Workspace, - ); - // Can't delete the old setting currently because it errors with `Unable to write to User Settings because is not a registered configuration` - // if (from !== to) { - // try { - // await this.update(from, undefined, ConfigurationTarget.Workspace); - // } - // catch { } - // } - } - } - - if (fromInspection.workspaceFolderValue !== undefined) { - if (toInspection === undefined || toInspection.workspaceFolderValue === undefined) { - await this.update( - to, - options.migrationFn != null - ? options.migrationFn(fromInspection.workspaceFolderValue) - : fromInspection.workspaceFolderValue, - ConfigurationTarget.WorkspaceFolder, - ); - // Can't delete the old setting currently because it errors with `Unable to write to User Settings because is not a registered configuration` - // if (from !== to) { - // try { - // await this.update(from, undefined, ConfigurationTarget.WorkspaceFolder); - // } - // catch { } - // } - } - } - } - - matches(match: T, section: ConfigPath, value: unknown): value is ConfigPathValue { - return match === section; - } - - name(section: T): string { - return section; - } - - update( - section: T, - value: ConfigPathValue | undefined, - target: ConfigurationTarget, - ): Thenable { - return workspace.getConfiguration(configPrefix).update(section, value, target); - } - - updateAny( - section: string, - value: any, - target: ConfigurationTarget, - scope?: ConfigurationScope | null, - ): Thenable { - return workspace - .getConfiguration(undefined, target === ConfigurationTarget.Global ? undefined : scope!) - .update(section, value, target); - } - - updateEffective(section: T, value: ConfigPathValue | undefined): Thenable { - const inspect = this.inspect(section)!; - if (inspect.workspaceFolderValue !== undefined) { - if (value === inspect.workspaceFolderValue) return Promise.resolve(undefined); - - return this.update(section, value, ConfigurationTarget.WorkspaceFolder); - } - - if (inspect.workspaceValue !== undefined) { - if (value === inspect.workspaceValue) return Promise.resolve(undefined); - - return this.update(section, value, ConfigurationTarget.Workspace); - } - - if (inspect.globalValue === value || (inspect.globalValue === undefined && value === inspect.defaultValue)) { - return Promise.resolve(undefined); - } - - return this.update( - section, - areEqual(value, inspect.defaultValue) ? undefined : value, - ConfigurationTarget.Global, - ); - } -} - -export const configuration = new Configuration(); - -type SubPath = Key extends string - ? T[Key] extends Record - ? - | `${Key}.${SubPath> & string}` - | `${Key}.${Exclude & string}` - : never - : never; - -export type Path = SubPath | keyof T; - -export type PathValue> = P extends `${infer Key}.${infer Rest}` - ? Key extends keyof T - ? Rest extends Path - ? PathValue - : never - : never - : P extends keyof T - ? T[P] - : never; - -export type ConfigPath = Path; -export type ConfigPathValue

= PathValue; diff --git a/src/constants.ts b/src/constants.ts index 2fa13a8..bda5e73 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,5 +1,5 @@ +export const commandPrefix = 'gitlens'; export const quickPickTitleMaxChars = 80; -export const slowCallWarningThreshold = 500; export const ImageMimetypes: Record = { '.png': 'image/png', @@ -403,14 +403,6 @@ export const enum GlyphChars { ZeroWidthSpace = '\u200b', } -export const enum LogLevel { - Off = 'off', - Error = 'error', - Warn = 'warn', - Info = 'info', - Debug = 'debug', -} - export const enum Schemes { DebugConsole = 'debug', File = 'file', diff --git a/src/container.ts b/src/container.ts index b2bd23e..fcf249c 100644 --- a/src/container.ts +++ b/src/container.ts @@ -8,8 +8,8 @@ import { ActionRunners } from './api/actionRunners'; import { setDefaultGravatarsStyle } from './avatars'; import { GitCodeLensController } from './codelens/codeLensController'; import type { ToggleFileAnnotationCommandArgs } from './commands'; -import type { FileAnnotationType, ModeConfig } from './configuration'; -import { AnnotationsToggleMode, configuration, DateSource, DateStyle, fromOutputLevel } from './configuration'; +import type { FileAnnotationType, ModeConfig } from './config'; +import { AnnotationsToggleMode, DateSource, DateStyle, fromOutputLevel } from './config'; import { Commands } from './constants'; import { EventBus } from './eventBus'; import { GitFileSystemProvider } from './git/fsProvider'; @@ -18,8 +18,6 @@ import { GitHubAuthenticationProvider } from './git/remotes/github'; import { GitLabAuthenticationProvider } from './git/remotes/gitlab'; import { RichRemoteProviderService } from './git/remotes/remoteProviderService'; import { LineHoverController } from './hovers/lineHoverController'; -import { Keyboard } from './keyboard'; -import { Logger } from './logger'; import { IntegrationAuthenticationService } from './plus/integrationAuthentication'; import { SubscriptionAuthenticationProvider } from './plus/subscription/authenticationProvider'; import { ServerConnection } from './plus/subscription/serverConnection'; @@ -31,15 +29,18 @@ import { TimelineWebviewView } from './plus/webviews/timeline/timelineWebviewVie import { StatusBarController } from './statusbar/statusBarController'; import type { Storage } from './storage'; import { executeCommand } from './system/command'; +import { configuration } from './system/configuration'; import { log } from './system/decorators/log'; import { memoize } from './system/decorators/memoize'; +import { Keyboard } from './system/keyboard'; +import { Logger } from './system/logger'; import { TelemetryService } from './telemetry/telemetry'; +import { UsageTracker } from './telemetry/usageTracker'; import { GitTerminalLinkProvider } from './terminal/linkProvider'; import { GitDocumentTracker } from './trackers/gitDocumentTracker'; import { GitLineTracker } from './trackers/gitLineTracker'; import { DeepLinkService } from './uris/deepLinks/deepLinkService'; import { UriService } from './uris/uriService'; -import { UsageTracker } from './usageTracker'; import { BranchesView } from './views/branchesView'; import { CommitsView } from './views/commitsView'; import { ContributorsView } from './views/contributorsView'; diff --git a/src/env/browser/platform.ts b/src/env/browser/platform.ts index 26eebd8..436a8a0 100644 --- a/src/env/browser/platform.ts +++ b/src/env/browser/platform.ts @@ -8,14 +8,8 @@ export const isMac = _platform === 'macOS' || _userAgent.indexOf('Macintosh') >= export const isWindows = _platform === 'Windows' || _userAgent.indexOf('Windows') >= 0; export function getPlatform(): string { - if (isWindows) { - return 'web-windows'; - } - if (isMac) { - return 'web-macOS'; - } - if (isLinux) { - return 'web-linux'; - } + if (isWindows) return 'web-windows'; + if (isMac) return 'web-macOS'; + if (isLinux) return 'web-linux'; return 'web'; } diff --git a/src/env/node/fetch.ts b/src/env/node/fetch.ts index bbaa4a6..232c13e 100644 --- a/src/env/node/fetch.ts +++ b/src/env/node/fetch.ts @@ -2,8 +2,8 @@ import * as process from 'process'; import * as url from 'url'; import { HttpsProxyAgent } from 'https-proxy-agent'; import fetch from 'node-fetch'; -import { configuration } from '../../configuration'; -import { Logger } from '../../logger'; +import { configuration } from '../../system/configuration'; +import { Logger } from '../../system/logger'; export { fetch }; export type { BodyInit, RequestInfo, RequestInit, Response } from 'node-fetch'; diff --git a/src/env/node/git/git.ts b/src/env/node/git/git.ts index f5beb03..202fffb 100644 --- a/src/env/node/git/git.ts +++ b/src/env/node/git/git.ts @@ -4,7 +4,7 @@ import * as process from 'process'; import type { CancellationToken, OutputChannel } from 'vscode'; import { Uri, window, workspace } from 'vscode'; import { hrtime } from '@env/hrtime'; -import { GlyphChars, LogLevel, slowCallWarningThreshold } from '../../../constants'; +import { GlyphChars } from '../../../constants'; import type { GitCommandOptions, GitSpawnOptions } from '../../../git/commandOptions'; import { GitErrorHandling } from '../../../git/commandOptions'; import type { GitDiffFilter } from '../../../git/models/diff'; @@ -14,8 +14,9 @@ import { GitBranchParser } from '../../../git/parsers/branchParser'; import { GitLogParser } from '../../../git/parsers/logParser'; import { GitReflogParser } from '../../../git/parsers/reflogParser'; import { GitTagParser } from '../../../git/parsers/tagParser'; -import { Logger } from '../../../logger'; import { join } from '../../../system/iterable'; +import { Logger } from '../../../system/logger'; +import { LogLevel, slowCallWarningThreshold } from '../../../system/logger.constants'; import { dirname, isAbsolute, isFolderGlob, joinPaths, normalizePath, splitPath } from '../../../system/path'; import { getDurationMilliseconds } from '../../../system/string'; import { compare, fromString } from '../../../system/version'; diff --git a/src/env/node/git/localGitProvider.ts b/src/env/node/git/localGitProvider.ts index d6d4496..c28a6f0 100644 --- a/src/env/node/git/localGitProvider.ts +++ b/src/env/node/git/localGitProvider.ts @@ -15,7 +15,6 @@ import type { GitExtension, } from '../../../@types/vscode.git'; import { getCachedAvatarUri } from '../../../avatars'; -import { configuration } from '../../../configuration'; import { CoreGitConfiguration, GlyphChars, Schemes } from '../../../constants'; import type { Container } from '../../../container'; import { emojify } from '../../../emojis'; @@ -127,9 +126,6 @@ import { getRemoteProviderMatcher, loadRemoteProviders } from '../../../git/remo import type { RichRemoteProvider } from '../../../git/remotes/richRemoteProvider'; import type { GitSearch, GitSearchResultData, GitSearchResults, SearchQuery } from '../../../git/search'; import { getGitArgsFromSearchQuery, getSearchQueryComparisonKey } from '../../../git/search'; -import { Logger } from '../../../logger'; -import type { LogScope } from '../../../logScope'; -import { getLogScope } from '../../../logScope'; import { showGenericErrorMessage, showGitDisabledErrorMessage, @@ -146,10 +142,14 @@ import type { } from '../../../plus/webviews/graph/graphWebview'; import { countStringLength, filterMap } from '../../../system/array'; import { TimedCancellationSource } from '../../../system/cancellation'; +import { configuration } from '../../../system/configuration'; import { gate } from '../../../system/decorators/gate'; import { debug, log } from '../../../system/decorators/log'; import { debounce } from '../../../system/function'; import { filterMap as filterMapIterable, find, first, join, last, map, some } from '../../../system/iterable'; +import { Logger } from '../../../system/logger'; +import type { LogScope } from '../../../system/logger.scope'; +import { getLogScope } from '../../../system/logger.scope'; import { commonBaseIndex, dirname, diff --git a/src/env/node/git/locator.ts b/src/env/node/git/locator.ts index fa93bb5..5986cca 100644 --- a/src/env/node/git/locator.ts +++ b/src/env/node/git/locator.ts @@ -1,6 +1,7 @@ import { join as joinPaths } from 'path'; import * as process from 'process'; -import { GlyphChars, LogLevel } from '../../../constants'; +import { GlyphChars } from '../../../constants'; +import { LogLevel } from '../../../system/logger.constants'; import { any } from '../../../system/promise'; import { Stopwatch } from '../../../system/stopwatch'; import { findExecutable, run } from './shell'; diff --git a/src/env/node/git/shell.ts b/src/env/node/git/shell.ts index 12aac7d..2f805b1 100644 --- a/src/env/node/git/shell.ts +++ b/src/env/node/git/shell.ts @@ -6,7 +6,7 @@ import { join as joinPaths } from 'path'; import * as process from 'process'; import { decode } from 'iconv-lite'; import type { CancellationToken } from 'vscode'; -import { Logger } from '../../../logger'; +import { Logger } from '../../../system/logger'; export const isWindows = process.platform === 'win32'; diff --git a/src/env/node/git/vslsGitProvider.ts b/src/env/node/git/vslsGitProvider.ts index f30d882..22dc5d3 100644 --- a/src/env/node/git/vslsGitProvider.ts +++ b/src/env/node/git/vslsGitProvider.ts @@ -5,8 +5,8 @@ import type { GitCommandOptions } from '../../../git/commandOptions'; import type { GitProviderDescriptor } from '../../../git/gitProvider'; import { GitProviderId } from '../../../git/gitProvider'; import type { Repository } from '../../../git/models/repository'; -import { Logger } from '../../../logger'; -import { getLogScope } from '../../../logScope'; +import { Logger } from '../../../system/logger'; +import { getLogScope } from '../../../system/logger.scope'; import { addVslsPrefixIfNeeded } from '../../../system/path'; import { Git } from './git'; import { LocalGitProvider } from './localGitProvider'; diff --git a/src/env/node/platform.ts b/src/env/node/platform.ts index 6d43a0c..fedd559 100644 --- a/src/env/node/platform.ts +++ b/src/env/node/platform.ts @@ -8,14 +8,8 @@ export const isMac = process.platform === 'darwin'; export const isWindows = process.platform === 'win32'; export function getPlatform(): string { - if (isWindows) { - return 'windows'; - } - if (isMac) { - return 'macOS'; - } - if (isLinux) { - return 'linux'; - } + if (isWindows) return 'windows'; + if (isMac) return 'macOS'; + if (isLinux) return 'linux'; return isWeb ? 'web' : 'unknown'; } diff --git a/src/env/node/providers.ts b/src/env/node/providers.ts index 0e91d16..a617a00 100644 --- a/src/env/node/providers.ts +++ b/src/env/node/providers.ts @@ -1,7 +1,7 @@ -import { configuration } from '../../configuration'; import type { Container } from '../../container'; import type { GitCommandOptions } from '../../git/commandOptions'; import type { GitProvider } from '../../git/gitProvider'; +import { configuration } from '../../system/configuration'; // import { GitHubGitProvider } from '../../plus/github/githubGitProvider'; import { Git } from './git/git'; import { LocalGitProvider } from './git/localGitProvider'; diff --git a/src/extension.ts b/src/extension.ts index acb7505..f07537d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -5,8 +5,8 @@ import { isWeb } from '@env/platform'; import { Api } from './api/api'; import type { CreatePullRequestActionContext, GitLensApi, OpenPullRequestActionContext } from './api/gitlens'; import type { CreatePullRequestOnRemoteCommandArgs, OpenPullRequestOnRemoteCommandArgs } from './commands'; -import { configuration, Configuration, fromOutputLevel, OutputLevel } from './configuration'; -import { Commands, ContextKeys, CoreCommands, LogLevel } from './constants'; +import { fromOutputLevel, OutputLevel } from './config'; +import { Commands, ContextKeys, CoreCommands } from './constants'; import { Container } from './container'; import { setContext } from './context'; import { isGitUri } from './git/gitUri'; @@ -14,7 +14,6 @@ import { getBranchNameWithoutRemote, isBranch } from './git/models/branch'; import { isCommit } from './git/models/commit'; import { isRepository } from './git/models/repository'; import { isTag } from './git/models/tag'; -import { Logger } from './logger'; import { showDebugLoggingWarningMessage, showInsidersErrorMessage, @@ -24,8 +23,11 @@ import { import { registerPartnerActionRunners } from './partners'; import { Storage, SyncedStorageKeys } from './storage'; import { executeCommand, executeCoreCommand, registerCommands } from './system/command'; +import { configuration, Configuration } from './system/configuration'; import { setDefaultDateLocales } from './system/date'; import { once } from './system/event'; +import { Logger } from './system/logger'; +import { LogLevel } from './system/logger.constants'; import { flatten } from './system/object'; import { Stopwatch } from './system/stopwatch'; import { compare, fromString, satisfies } from './system/version'; @@ -56,7 +58,7 @@ export async function activate(context: ExtensionContext): Promise; -} - -const keyNoopCommand = Object.create(null) as KeyCommand; -export { keyNoopCommand as KeyNoopCommand }; - -export const keys = [ - 'left', - 'alt+left', - 'ctrl+left', - 'right', - 'alt+right', - 'ctrl+right', - 'alt+,', - 'alt+.', - 'escape', -] as const; -export type Keys = (typeof keys)[number]; - -export type KeyMapping = { [K in Keys]?: KeyCommand | (() => Promise) }; -type IndexableKeyMapping = KeyMapping & { - [index: string]: KeyCommand | (() => Promise) | undefined; -}; - -const mappings: KeyMapping[] = []; - -export class KeyboardScope implements Disposable { - private readonly _mapping: IndexableKeyMapping; - constructor(mapping: KeyMapping) { - this._mapping = mapping; - for (const key in this._mapping) { - this._mapping[key] = this._mapping[key] ?? keyNoopCommand; - } - - mappings.push(this._mapping); - } - - @log({ - args: false, - prefix: context => `${context.prefix}[${mappings.length}]`, - }) - async dispose() { - const index = mappings.indexOf(this._mapping); - - const scope = getLogScope(); - if (scope != null) { - scope.exitDetails = ` \u2022 index=${index}`; - } - - if (index === mappings.length - 1) { - mappings.pop(); - await this.updateKeyCommandsContext(mappings[mappings.length - 1]); - } else { - mappings.splice(index, 1); - } - } - - private _paused = true; - get paused() { - return this._paused; - } - - @log({ - args: false, - prefix: (context, key) => `${context.prefix}[${mappings.length}](${key})`, - }) - async clearKeyCommand(key: Keys) { - const scope = getLogScope(); - - const mapping = mappings[mappings.length - 1]; - if (mapping !== this._mapping || mapping[key] == null) { - if (scope != null) { - scope.exitDetails = ' \u2022 skipped'; - } - - return; - } - - mapping[key] = undefined; - await setContext(`${ContextKeys.KeyPrefix}${key}`, false); - } - - @log({ - args: false, - prefix: context => `${context.prefix}(paused=${context.instance._paused})`, - }) - async pause(keys?: Keys[]) { - if (this._paused) return; - - this._paused = true; - const mapping = (Object.keys(this._mapping) as Keys[]).reduce((accumulator, key) => { - accumulator[key] = keys == null || keys.includes(key) ? undefined : this._mapping[key]; - return accumulator; - }, Object.create(null)); - - await this.updateKeyCommandsContext(mapping); - } - - @log({ - args: false, - prefix: context => `${context.prefix}(paused=${context.instance._paused})`, - }) - async resume() { - if (!this._paused) return; - - this._paused = false; - await this.updateKeyCommandsContext(this._mapping); - } - - async start() { - await this.resume(); - } - - @log({ - args: false, - prefix: (context, key) => `${context.prefix}[${mappings.length}](${key})`, - }) - async setKeyCommand(key: Keys, command: KeyCommand | (() => Promise)) { - const scope = getLogScope(); - - const mapping = mappings[mappings.length - 1]; - if (mapping !== this._mapping) { - if (scope != null) { - scope.exitDetails = ' \u2022 skipped'; - } - - return; - } - - const set = Boolean(mapping[key]); - - mapping[key] = command; - if (!set) { - await setContext(`${ContextKeys.KeyPrefix}${key}`, true); - } - } - - private async updateKeyCommandsContext(mapping: KeyMapping) { - await Promise.all(keys.map(key => setContext(`${ContextKeys.KeyPrefix}${key}`, Boolean(mapping?.[key])))); - } -} - -export class Keyboard implements Disposable { - private readonly _disposable: Disposable; - - constructor() { - const subscriptions = keys.map(key => registerCommand(`gitlens.key.${key}`, () => this.execute(key), this)); - this._disposable = Disposable.from(...subscriptions); - } - - dispose() { - this._disposable.dispose(); - } - - @log({ - args: false, - prefix: (context, mapping) => - `${context.prefix}[${mappings.length}](${mapping === undefined ? '' : Object.keys(mapping).join(',')})`, - }) - createScope(mapping?: KeyMapping): KeyboardScope { - return new KeyboardScope({ ...mapping }); - } - - @log({ - args: false, - prefix: (context, mapping) => - `${context.prefix}[${mappings.length}](${mapping === undefined ? '' : Object.keys(mapping).join(',')})`, - }) - async beginScope(mapping?: KeyMapping): Promise { - const scope = this.createScope(mapping); - await scope.start(); - return scope; - } - - @log() - async execute(key: Keys): Promise { - const scope = getLogScope(); - - if (!mappings.length) { - if (scope != null) { - scope.exitDetails = ' \u2022 skipped, no mappings'; - } - - return; - } - - try { - const mapping = mappings[mappings.length - 1]; - - let command = mapping[key] as KeyCommand | (() => Promise); - if (typeof command === 'function') { - command = await command(); - } - if (typeof command?.onDidPressKey !== 'function') { - if (scope != null) { - scope.exitDetails = ' \u2022 skipped, no callback'; - } - - return; - } - - await command.onDidPressKey(key); - } catch (ex) { - Logger.error(ex, scope); - } - } -} diff --git a/src/logScope.ts b/src/logScope.ts deleted file mode 100644 index 345ee94..0000000 --- a/src/logScope.ts +++ /dev/null @@ -1,41 +0,0 @@ -const maxSmallIntegerV8 = 2 ** 30; // Max number that can be stored in V8's smis (small integers) - -const scopes = new Map(); -let scopeCounter = 0; - -export interface LogScope { - readonly scopeId?: number; - readonly prefix: string; - exitDetails?: string; -} - -export function clearLogScope(scopeId: number) { - scopes.delete(scopeId); -} - -export function getLogScope(): LogScope | undefined { - return scopes.get(scopeCounter); -} - -export function getNewLogScope(prefix: string): LogScope { - const scopeId = getNextLogScopeId(); - return { - scopeId: scopeId, - prefix: `[${String(scopeId).padStart(5)}] ${prefix}`, - }; -} - -export function getLogScopeId(): number { - return scopeCounter; -} - -export function getNextLogScopeId(): number { - if (scopeCounter === maxSmallIntegerV8) { - scopeCounter = 0; - } - return ++scopeCounter; -} - -export function setLogScope(scopeId: number, scope: LogScope) { - scopes.set(scopeId, scope); -} diff --git a/src/logger.ts b/src/logger.ts deleted file mode 100644 index 2c9f5b1..0000000 --- a/src/logger.ts +++ /dev/null @@ -1,254 +0,0 @@ -import { LogLevel } from './constants'; -import type { LogScope } from './logScope'; - -const emptyStr = ''; - -const enum OrderedLevel { - Off = 0, - Error = 1, - Warn = 2, - Info = 3, - Debug = 4, -} - -export interface LogChannelProvider { - readonly name: string; - createChannel(name: string): LogChannel; - toLoggable?(o: unknown): string | undefined; -} - -export interface LogChannel { - readonly name: string; - appendLine(value: string): void; - dispose?(): void; - show?(preserveFocus?: boolean): void; -} - -export const Logger = new (class Logger { - private output: LogChannel | undefined; - private provider: LogChannelProvider | undefined; - - configure(provider: LogChannelProvider, logLevel: LogLevel, debugging: boolean = false) { - this.provider = provider; - - this._isDebugging = debugging; - this.logLevel = logLevel; - } - - enabled(level: LogLevel): boolean { - return this.level >= toOrderedLevel(level); - } - - private _isDebugging = false; - get isDebugging() { - return this._isDebugging; - } - - private level: OrderedLevel = OrderedLevel.Off; - private _logLevel: LogLevel = LogLevel.Off; - get logLevel(): LogLevel { - return this._logLevel; - } - set logLevel(value: LogLevel) { - this._logLevel = value; - this.level = toOrderedLevel(this._logLevel); - - if (value === LogLevel.Off) { - this.output?.dispose?.(); - this.output = undefined; - } else { - this.output = this.output ?? this.provider!.createChannel(this.provider!.name); - } - } - - get timestamp(): string { - return `[${new Date().toISOString().replace(/T/, ' ').slice(0, -1)}]`; - } - - debug(message: string, ...params: any[]): void; - debug(scope: LogScope | undefined, message: string, ...params: any[]): void; - debug(scopeOrMessage: LogScope | string | undefined, ...params: any[]): void { - if (this.level < OrderedLevel.Debug && !this.isDebugging) return; - - let message; - if (typeof scopeOrMessage === 'string') { - message = scopeOrMessage; - } else { - message = params.shift(); - - if (scopeOrMessage != null) { - message = `${scopeOrMessage.prefix} ${message ?? emptyStr}`; - } - } - - if (this.isDebugging) { - console.log(this.timestamp, `[${this.provider!.name}]`, message ?? emptyStr, ...params); - } - - if (this.output == null || this.level < OrderedLevel.Debug) return; - this.output.appendLine(`${this.timestamp} ${message ?? emptyStr}${this.toLoggableParams(true, params)}`); - } - - error(ex: Error | unknown, message?: string, ...params: any[]): void; - error(ex: Error | unknown, scope?: LogScope, message?: string, ...params: any[]): void; - error(ex: Error | unknown, scopeOrMessage: LogScope | string | undefined, ...params: any[]): void { - if (this.level < OrderedLevel.Error && !this.isDebugging) return; - - let message; - if (scopeOrMessage == null || typeof scopeOrMessage === 'string') { - message = scopeOrMessage; - } else { - message = `${scopeOrMessage.prefix} ${params.shift() ?? emptyStr}`; - } - - if (message == null) { - const stack = ex instanceof Error ? ex.stack : undefined; - if (stack) { - const match = /.*\s*?at\s(.+?)\s/.exec(stack); - if (match != null) { - message = match[1]; - } - } - } - - if (this.isDebugging) { - console.error(this.timestamp, `[${this.provider!.name}]`, message ?? emptyStr, ...params, ex); - } - - if (this.output == null || this.level < OrderedLevel.Error) return; - this.output.appendLine( - `${this.timestamp} ${message ?? emptyStr}${this.toLoggableParams(false, params)}\n${String(ex)}`, - ); - } - - log(message: string, ...params: any[]): void; - log(scope: LogScope | undefined, message: string, ...params: any[]): void; - log(scopeOrMessage: LogScope | string | undefined, ...params: any[]): void { - if (this.level < OrderedLevel.Info && !this.isDebugging) return; - - let message; - if (typeof scopeOrMessage === 'string') { - message = scopeOrMessage; - } else { - message = params.shift(); - - if (scopeOrMessage != null) { - message = `${scopeOrMessage.prefix} ${message ?? emptyStr}`; - } - } - - if (this.isDebugging) { - console.log(this.timestamp, `[${this.provider!.name}]`, message ?? emptyStr, ...params); - } - - if (this.output == null || this.level < OrderedLevel.Info) return; - this.output.appendLine(`${this.timestamp} ${message ?? emptyStr}${this.toLoggableParams(false, params)}`); - } - - warn(message: string, ...params: any[]): void; - warn(scope: LogScope | undefined, message: string, ...params: any[]): void; - warn(scopeOrMessage: LogScope | string | undefined, ...params: any[]): void { - if (this.level < OrderedLevel.Warn && !this.isDebugging) return; - - let message; - if (typeof scopeOrMessage === 'string') { - message = scopeOrMessage; - } else { - message = params.shift(); - - if (scopeOrMessage != null) { - message = `${scopeOrMessage.prefix} ${message ?? emptyStr}`; - } - } - - if (this.isDebugging) { - console.warn(this.timestamp, `[${this.provider!.name}]`, message ?? emptyStr, ...params); - } - - if (this.output == null || this.level < OrderedLevel.Warn) return; - this.output.appendLine(`${this.timestamp} ${message ?? emptyStr}${this.toLoggableParams(false, params)}`); - } - - showOutputChannel(preserveFocus?: boolean): void { - this.output?.show?.(preserveFocus); - } - - toLoggable(o: any, sanitize?: ((key: string, value: any) => any) | undefined) { - if (typeof o !== 'object') return String(o); - - const loggable = this.provider!.toLoggable?.(o); - if (loggable != null) return loggable; - - try { - return JSON.stringify(o, sanitize); - } catch { - return ''; - } - } - - private toLoggableParams(debugOnly: boolean, params: any[]) { - if (params.length === 0 || (debugOnly && this.level < OrderedLevel.Debug && !this.isDebugging)) { - return emptyStr; - } - - const loggableParams = params.map(p => this.toLoggable(p)).join(', '); - return loggableParams.length !== 0 ? ` \u2014 ${loggableParams}` : emptyStr; - } -})(); - -function toOrderedLevel(logLevel: LogLevel): OrderedLevel { - switch (logLevel) { - case LogLevel.Off: - return OrderedLevel.Off; - case LogLevel.Error: - return OrderedLevel.Error; - case LogLevel.Warn: - return OrderedLevel.Warn; - case LogLevel.Info: - return OrderedLevel.Info; - case LogLevel.Debug: - return OrderedLevel.Debug; - default: - return OrderedLevel.Off; - } -} - -export function getLoggableName(instance: Function | object) { - let name: string; - if (typeof instance === 'function') { - if (instance.prototype?.constructor == null) return instance.name; - - name = instance.prototype.constructor.name ?? emptyStr; - } else { - name = instance.constructor?.name ?? emptyStr; - } - - // Strip webpack module name (since I never name classes with an _) - const index = name.indexOf('_'); - return index === -1 ? name : name.substr(index + 1); -} - -export interface LogProvider { - enabled(logLevel: LogLevel): boolean; - log(logLevel: LogLevel, scope: LogScope | undefined, message: string, ...params: any[]): void; -} - -export const defaultLogProvider: LogProvider = { - enabled: (logLevel: LogLevel) => Logger.enabled(logLevel), - log: (logLevel: LogLevel, scope: LogScope | undefined, message: string, ...params: any[]) => { - switch (logLevel) { - case LogLevel.Error: - Logger.error('', scope, message, ...params); - break; - case LogLevel.Warn: - Logger.warn(scope, message, ...params); - break; - case LogLevel.Info: - Logger.log(scope, message, ...params); - break; - default: - Logger.debug(scope, message, ...params); - break; - } - }, -}; diff --git a/src/messages.ts b/src/messages.ts index d632eab..499a200 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -1,10 +1,12 @@ import type { MessageItem } from 'vscode'; import { ConfigurationTarget, env, Uri, window } from 'vscode'; -import { configuration, SuppressedMessages } from './configuration'; -import { Commands, LogLevel } from './constants'; +import { SuppressedMessages } from './config'; +import { Commands } from './constants'; import type { GitCommit } from './git/models/commit'; -import { Logger } from './logger'; import { executeCommand } from './system/command'; +import { configuration } from './system/configuration'; +import { Logger } from './system/logger'; +import { LogLevel } from './system/logger.constants'; export function showCommitHasNoPreviousCommitWarningMessage(commit?: GitCommit): Promise { if (commit == null) { diff --git a/src/plus/github/github.ts b/src/plus/github/github.ts index 345b316..bafc130 100644 --- a/src/plus/github/github.ts +++ b/src/plus/github/github.ts @@ -7,8 +7,6 @@ import type { Event } from 'vscode'; import { Disposable, EventEmitter, Uri, window } from 'vscode'; import { fetch, getProxyAgent, wrapForForcedInsecureSSL } from '@env/fetch'; import { isWeb } from '@env/platform'; -import { configuration } from '../../configuration'; -import { LogLevel } from '../../constants'; import type { Container } from '../../container'; import { AuthenticationError, @@ -27,15 +25,17 @@ import { isSha } from '../../git/models/reference'; import type { GitUser } from '../../git/models/user'; import { getGitHubNoReplyAddressParts } from '../../git/remotes/github'; import type { RichRemoteProvider } from '../../git/remotes/richRemoteProvider'; -import { Logger } from '../../logger'; -import type { LogScope } from '../../logScope'; -import { getLogScope } from '../../logScope'; import { showIntegrationRequestFailed500WarningMessage, showIntegrationRequestTimedOutWarningMessage, } from '../../messages'; import { uniqueBy } from '../../system/array'; +import { configuration } from '../../system/configuration'; import { debug } from '../../system/decorators/log'; +import { Logger } from '../../system/logger'; +import { LogLevel } from '../../system/logger.constants'; +import type { LogScope } from '../../system/logger.scope'; +import { getLogScope } from '../../system/logger.scope'; import { Stopwatch } from '../../system/stopwatch'; import { base64 } from '../../system/string'; import type { Version } from '../../system/version'; diff --git a/src/plus/github/githubGitProvider.ts b/src/plus/github/githubGitProvider.ts index 83f0d22..3198976 100644 --- a/src/plus/github/githubGitProvider.ts +++ b/src/plus/github/githubGitProvider.ts @@ -11,7 +11,6 @@ import type { } from 'vscode'; import { authentication, EventEmitter, FileType, Uri, window, workspace } from 'vscode'; import { encodeUtf8Hex } from '@env/hex'; -import { configuration } from '../../configuration'; import { CharCode, ContextKeys, Schemes } from '../../constants'; import type { Container } from '../../container'; import { setContext } from '../../context'; @@ -79,12 +78,13 @@ import { getRemoteProviderMatcher, loadRemoteProviders } from '../../git/remotes import type { RichRemoteProvider } from '../../git/remotes/richRemoteProvider'; import type { GitSearch, GitSearchResultData, GitSearchResults, SearchQuery } from '../../git/search'; import { getSearchQueryComparisonKey, parseSearchQuery } from '../../git/search'; -import { Logger } from '../../logger'; -import type { LogScope } from '../../logScope'; -import { getLogScope } from '../../logScope'; +import { configuration } from '../../system/configuration'; import { gate } from '../../system/decorators/gate'; import { debug, log } from '../../system/decorators/log'; import { filterMap, first, last, some } from '../../system/iterable'; +import { Logger } from '../../system/logger'; +import type { LogScope } from '../../system/logger.scope'; +import { getLogScope } from '../../system/logger.scope'; import { isAbsolute, isFolderGlob, maybeUri, normalizePath, relative } from '../../system/path'; import { fastestSettled, getSettledValue } from '../../system/promise'; import { serializeWebviewItemContext } from '../../system/webview'; diff --git a/src/plus/gitlab/gitlab.ts b/src/plus/gitlab/gitlab.ts index 64907c9..9324063 100644 --- a/src/plus/gitlab/gitlab.ts +++ b/src/plus/gitlab/gitlab.ts @@ -3,8 +3,6 @@ import { Disposable, Uri, window } from 'vscode'; import type { RequestInit, Response } from '@env/fetch'; import { fetch, getProxyAgent, wrapForForcedInsecureSSL } from '@env/fetch'; import { isWeb } from '@env/platform'; -import { configuration } from '../../configuration'; -import { LogLevel } from '../../constants'; import type { Container } from '../../container'; import { AuthenticationError, @@ -20,14 +18,16 @@ import type { IssueOrPullRequest } from '../../git/models/issue'; import { IssueOrPullRequestType } from '../../git/models/issue'; import { PullRequest } from '../../git/models/pullRequest'; import type { RichRemoteProvider } from '../../git/remotes/richRemoteProvider'; -import { Logger } from '../../logger'; -import type { LogScope } from '../../logScope'; -import { getLogScope } from '../../logScope'; import { showIntegrationRequestFailed500WarningMessage, showIntegrationRequestTimedOutWarningMessage, } from '../../messages'; +import { configuration } from '../../system/configuration'; import { debug } from '../../system/decorators/log'; +import { Logger } from '../../system/logger'; +import { LogLevel } from '../../system/logger.constants'; +import type { LogScope } from '../../system/logger.scope'; +import { getLogScope } from '../../system/logger.scope'; import { Stopwatch } from '../../system/stopwatch'; import { equalsIgnoreCase } from '../../system/string'; import type { GitLabCommit, GitLabIssue, GitLabMergeRequest, GitLabMergeRequestREST, GitLabUser } from './models'; diff --git a/src/plus/remotehub.ts b/src/plus/remotehub.ts index 56dddda..45034bb 100644 --- a/src/plus/remotehub.ts +++ b/src/plus/remotehub.ts @@ -1,7 +1,7 @@ import type { Uri } from 'vscode'; import { extensions } from 'vscode'; import { ExtensionNotFoundError } from '../errors'; -import { Logger } from '../logger'; +import { Logger } from '../system/logger'; export async function getRemoteHubApi(): Promise; export async function getRemoteHubApi(silent: false): Promise; diff --git a/src/plus/subscription/authenticationProvider.ts b/src/plus/subscription/authenticationProvider.ts index 460ce85..aa3b488 100644 --- a/src/plus/subscription/authenticationProvider.ts +++ b/src/plus/subscription/authenticationProvider.ts @@ -6,9 +6,9 @@ import type { import { authentication, Disposable, EventEmitter, extensions, window } from 'vscode'; import { uuid } from '@env/crypto'; import type { Container } from '../../container'; -import { Logger } from '../../logger'; -import { getLogScope } from '../../logScope'; import { debug } from '../../system/decorators/log'; +import { Logger } from '../../system/logger'; +import { getLogScope } from '../../system/logger.scope'; import type { ServerConnection } from './serverConnection'; interface StoredSession { diff --git a/src/plus/subscription/serverConnection.ts b/src/plus/subscription/serverConnection.ts index f03a667..74a5c09 100644 --- a/src/plus/subscription/serverConnection.ts +++ b/src/plus/subscription/serverConnection.ts @@ -4,12 +4,12 @@ import { uuid } from '@env/crypto'; import type { RequestInfo, RequestInit, Response } from '@env/fetch'; import { fetch, getProxyAgent } from '@env/fetch'; import type { Container } from '../../container'; -import { Logger } from '../../logger'; -import { getLogScope } from '../../logScope'; import { debug } from '../../system/decorators/log'; import { memoize } from '../../system/decorators/memoize'; import type { DeferredEvent, DeferredEventExecutor } from '../../system/event'; import { promisifyDeferred } from '../../system/event'; +import { Logger } from '../../system/logger'; +import { getLogScope } from '../../system/logger.scope'; export const AuthenticationUriPathPrefix = 'did-authenticate'; // TODO: What user-agent should we use? diff --git a/src/plus/subscription/subscriptionService.ts b/src/plus/subscription/subscriptionService.ts index 0effbca..55b8adc 100644 --- a/src/plus/subscription/subscriptionService.ts +++ b/src/plus/subscription/subscriptionService.ts @@ -22,14 +22,11 @@ import { } from 'vscode'; import { fetch, getProxyAgent } from '@env/fetch'; import { getPlatform } from '@env/platform'; -import { configuration } from '../../configuration'; import { Commands, ContextKeys } from '../../constants'; import type { Container } from '../../container'; import { setContext } from '../../context'; import { AccountValidationError } from '../../errors'; import type { RepositoriesChangeEvent } from '../../git/gitProviderService'; -import { Logger } from '../../logger'; -import { getLogScope } from '../../logScope'; import { showMessage } from '../../messages'; import type { Subscription } from '../../subscription'; import { @@ -46,12 +43,15 @@ import { SubscriptionState, } from '../../subscription'; import { executeCommand, registerCommand } from '../../system/command'; +import { configuration } from '../../system/configuration'; import { createFromDateDelta } from '../../system/date'; import { gate } from '../../system/decorators/gate'; import { debug, log } from '../../system/decorators/log'; import { memoize } from '../../system/decorators/memoize'; import type { Deferrable } from '../../system/function'; import { debounce, once } from '../../system/function'; +import { Logger } from '../../system/logger'; +import { getLogScope } from '../../system/logger.scope'; import { flatten } from '../../system/object'; import { pluralize } from '../../system/string'; import { openWalkthrough } from '../../system/utils'; diff --git a/src/plus/subscription/utils.ts b/src/plus/subscription/utils.ts index 031bad8..81d786c 100644 --- a/src/plus/subscription/utils.ts +++ b/src/plus/subscription/utils.ts @@ -1,8 +1,8 @@ import type { MessageItem } from 'vscode'; import { window } from 'vscode'; -import { configuration } from '../../configuration'; import { ContextKeys } from '../../constants'; import { getContext } from '../../context'; +import { configuration } from '../../system/configuration'; export function arePlusFeaturesEnabled(): boolean { return getContext(ContextKeys.PlusEnabled, configuration.get('plusFeatures.enabled', undefined, true)); diff --git a/src/plus/webviews/graph/graphWebview.ts b/src/plus/webviews/graph/graphWebview.ts index 44460db..4ffc85b 100644 --- a/src/plus/webviews/graph/graphWebview.ts +++ b/src/plus/webviews/graph/graphWebview.ts @@ -27,8 +27,7 @@ import type { ShowCommitsInViewCommandArgs, } from '../../../commands'; import { parseCommandContext } from '../../../commands/base'; -import type { Config } from '../../../configuration'; -import { configuration } from '../../../configuration'; +import type { Config } from '../../../config'; import { Commands, ContextKeys, CoreCommands, CoreGitCommands, GlyphChars } from '../../../constants'; import type { Container } from '../../../container'; import { getContext, onDidChangeContext } from '../../../context'; @@ -74,6 +73,7 @@ import { executeCoreGitCommand, registerCommand, } from '../../../system/command'; +import { configuration } from '../../../system/configuration'; import { gate } from '../../../system/decorators/gate'; import { debug } from '../../../system/decorators/log'; import type { Deferrable } from '../../../system/function'; diff --git a/src/plus/webviews/timeline/timelineWebview.ts b/src/plus/webviews/timeline/timelineWebview.ts index f5cfc2a..7dde0be 100644 --- a/src/plus/webviews/timeline/timelineWebview.ts +++ b/src/plus/webviews/timeline/timelineWebview.ts @@ -1,7 +1,6 @@ 'use strict'; import type { Disposable, TextEditor, ViewColumn } from 'vscode'; import { Uri, window } from 'vscode'; -import { configuration } from '../../../configuration'; import { Commands, ContextKeys } from '../../../constants'; import type { Container } from '../../../container'; import { PlusFeatures } from '../../../features'; @@ -11,6 +10,7 @@ import { getChangedFilesCount } from '../../../git/models/commit'; import type { RepositoryChangeEvent } from '../../../git/models/repository'; import { RepositoryChange, RepositoryChangeComparisonMode } from '../../../git/models/repository'; import { registerCommand } from '../../../system/command'; +import { configuration } from '../../../system/configuration'; import { createFromDateDelta } from '../../../system/date'; import { debug } from '../../../system/decorators/log'; import type { Deferrable } from '../../../system/function'; diff --git a/src/plus/webviews/timeline/timelineWebviewView.ts b/src/plus/webviews/timeline/timelineWebviewView.ts index 5e5ee51..467fd51 100644 --- a/src/plus/webviews/timeline/timelineWebviewView.ts +++ b/src/plus/webviews/timeline/timelineWebviewView.ts @@ -1,7 +1,6 @@ 'use strict'; import type { Disposable, TextEditor } from 'vscode'; import { commands, Uri, window } from 'vscode'; -import { configuration } from '../../../configuration'; import { Commands, ContextKeys } from '../../../constants'; import type { Container } from '../../../container'; import type { FileSelectedEvent } from '../../../eventBus'; @@ -12,6 +11,7 @@ import { getChangedFilesCount } from '../../../git/models/commit'; import type { RepositoryChangeEvent } from '../../../git/models/repository'; import { RepositoryChange, RepositoryChangeComparisonMode } from '../../../git/models/repository'; import { registerCommand } from '../../../system/command'; +import { configuration } from '../../../system/configuration'; import { createFromDateDelta } from '../../../system/date'; import { debug } from '../../../system/decorators/log'; import type { Deferrable } from '../../../system/function'; diff --git a/src/quickpicks/commitPicker.ts b/src/quickpicks/commitPicker.ts index a390d06..358e5b3 100644 --- a/src/quickpicks/commitPicker.ts +++ b/src/quickpicks/commitPicker.ts @@ -1,12 +1,12 @@ import type { Disposable } from 'vscode'; import { window } from 'vscode'; -import { configuration } from '../configuration'; import { Container } from '../container'; import type { GitCommit, GitStashCommit } from '../git/models/commit'; import type { GitLog } from '../git/models/log'; import type { GitStash } from '../git/models/stash'; -import type { KeyboardScope, Keys } from '../keyboard'; +import { configuration } from '../system/configuration'; import { filter, map } from '../system/iterable'; +import type { KeyboardScope, Keys } from '../system/keyboard'; import { isPromise } from '../system/promise'; import { getQuickPickIgnoreFocusOut } from '../system/utils'; import { CommandQuickPickItem } from './items/common'; diff --git a/src/quickpicks/items/commits.ts b/src/quickpicks/items/commits.ts index c1c5b2f..8ed5ad1 100644 --- a/src/quickpicks/items/commits.ts +++ b/src/quickpicks/items/commits.ts @@ -11,7 +11,7 @@ import type { GitCommit } from '../../git/models/commit'; import type { GitFile, GitFileChange } from '../../git/models/file'; import { getGitFileFormattedDirectory, getGitFileStatusCodicon } from '../../git/models/file'; import type { GitStatusFile } from '../../git/models/status'; -import type { Keys } from '../../keyboard'; +import type { Keys } from '../../system/keyboard'; import { basename } from '../../system/path'; import { pad } from '../../system/string'; import { CommandQuickPickItem } from './common'; diff --git a/src/quickpicks/items/common.ts b/src/quickpicks/items/common.ts index 6efb97a..fb3da5d 100644 --- a/src/quickpicks/items/common.ts +++ b/src/quickpicks/items/common.ts @@ -1,7 +1,7 @@ import type { QuickPickItem } from 'vscode'; import { commands, QuickPickItemKind } from 'vscode'; import type { Commands } from '../../constants'; -import type { Keys } from '../../keyboard'; +import type { Keys } from '../../system/keyboard'; declare module 'vscode' { interface QuickPickItem { diff --git a/src/quickpicks/modePicker.ts b/src/quickpicks/modePicker.ts index 6624ead..946a564 100644 --- a/src/quickpicks/modePicker.ts +++ b/src/quickpicks/modePicker.ts @@ -1,7 +1,7 @@ import type { QuickPickItem } from 'vscode'; import { window } from 'vscode'; -import { configuration } from '../configuration'; import { GlyphChars } from '../constants'; +import { configuration } from '../system/configuration'; export interface ModesQuickPickItem extends QuickPickItem { key: string | undefined; diff --git a/src/quickpicks/referencePicker.ts b/src/quickpicks/referencePicker.ts index 71c7fa1..537ba1a 100644 --- a/src/quickpicks/referencePicker.ts +++ b/src/quickpicks/referencePicker.ts @@ -14,7 +14,7 @@ import type { BranchSortOptions, GitBranch } from '../git/models/branch'; import type { GitReference } from '../git/models/reference'; import { isBranchReference, isRevisionReference, isTagReference } from '../git/models/reference'; import type { GitTag, TagSortOptions } from '../git/models/tag'; -import type { KeyboardScope, Keys } from '../keyboard'; +import type { KeyboardScope, Keys } from '../system/keyboard'; import { getQuickPickIgnoreFocusOut } from '../system/utils'; import type { BranchQuickPickItem, RefQuickPickItem, TagQuickPickItem } from './items/gitCommands'; import { createRefQuickPickItem } from './items/gitCommands'; diff --git a/src/quickpicks/remoteProviderPicker.ts b/src/quickpicks/remoteProviderPicker.ts index 1b4fa2d..13dba1d 100644 --- a/src/quickpicks/remoteProviderPicker.ts +++ b/src/quickpicks/remoteProviderPicker.ts @@ -9,7 +9,7 @@ import { GitRemote } from '../git/models/remote'; import type { RemoteResource } from '../git/models/remoteResource'; import { getNameFromRemoteResource, RemoteResourceType } from '../git/models/remoteResource'; import type { RemoteProvider } from '../git/remotes/remoteProvider'; -import type { Keys } from '../keyboard'; +import type { Keys } from '../system/keyboard'; import { getSettledValue } from '../system/promise'; import { getQuickPickIgnoreFocusOut } from '../system/utils'; import { CommandQuickPickItem } from './items/common'; diff --git a/src/statusbar/statusBarController.ts b/src/statusbar/statusBarController.ts index c1c9624..bcba214 100644 --- a/src/statusbar/statusBarController.ts +++ b/src/statusbar/statusBarController.ts @@ -1,19 +1,20 @@ import type { CancellationToken, ConfigurationChangeEvent, StatusBarItem, TextEditor, Uri } from 'vscode'; import { CancellationTokenSource, Disposable, MarkdownString, StatusBarAlignment, window } from 'vscode'; import type { ToggleFileChangesAnnotationCommandArgs } from '../commands/toggleFileAnnotations'; -import { configuration, FileAnnotationType, StatusBarCommand } from '../configuration'; +import { FileAnnotationType, StatusBarCommand } from '../config'; import { Commands, GlyphChars } from '../constants'; import type { Container } from '../container'; import { CommitFormatter } from '../git/formatters/commitFormatter'; import type { GitCommit } from '../git/models/commit'; import type { PullRequest } from '../git/models/pullRequest'; import { detailsMessage } from '../hovers/hovers'; -import { Logger } from '../logger'; -import type { LogScope } from '../logScope'; -import { getLogScope } from '../logScope'; import { asCommand } from '../system/command'; +import { configuration } from '../system/configuration'; import { debug } from '../system/decorators/log'; import { once } from '../system/event'; +import { Logger } from '../system/logger'; +import type { LogScope } from '../system/logger.scope'; +import { getLogScope } from '../system/logger.scope'; import { PromiseCancelledError } from '../system/promise'; import { isTextEditor } from '../system/utils'; import type { LinesChangeEvent } from '../trackers/gitLineTracker'; diff --git a/src/storage.ts b/src/storage.ts index 1edc416..1071b12 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -4,7 +4,7 @@ import type { ViewShowBranchComparison } from './config'; import type { StoredSearchQuery } from './git/search'; import type { Subscription } from './subscription'; import { debug } from './system/decorators/log'; -import type { TrackedUsage, TrackedUsageKeys } from './usageTracker'; +import type { TrackedUsage, TrackedUsageKeys } from './telemetry/usageTracker'; import type { CompletedActions } from './webviews/home/protocol'; export type StorageChangeEvent = diff --git a/src/system/comparers.ts b/src/system/comparers.ts new file mode 100644 index 0000000..407340b --- /dev/null +++ b/src/system/comparers.ts @@ -0,0 +1,36 @@ +import type { TextEditor, Uri } from 'vscode'; + +abstract class Comparer { + abstract equals(lhs: T, rhs: T): boolean; +} + +class UriComparer extends Comparer { + equals(lhs: Uri | undefined, rhs: Uri | undefined, options: { exact?: boolean } = { exact: false }) { + if (lhs === rhs) return true; + if (lhs == null || rhs == null) return false; + + if (options.exact) { + return lhs.toString() === rhs.toString(); + } + return lhs.scheme === rhs.scheme && lhs.fsPath === rhs.fsPath; + } +} + +class TextEditorComparer extends Comparer { + equals( + lhs: TextEditor | undefined, + rhs: TextEditor | undefined, + options: { usePosition: boolean } = { usePosition: false }, + ) { + if (lhs === rhs) return true; + if (lhs == null || rhs == null) return false; + + if (options.usePosition && lhs.viewColumn !== rhs.viewColumn) return false; + + return lhs.document === rhs.document; + } +} + +const textEditorComparer = new TextEditorComparer(); +const uriComparer = new UriComparer(); +export { textEditorComparer as TextEditorComparer, uriComparer as UriComparer }; diff --git a/src/system/configuration.ts b/src/system/configuration.ts new file mode 100644 index 0000000..1aa271b --- /dev/null +++ b/src/system/configuration.ts @@ -0,0 +1,343 @@ +import type { ConfigurationChangeEvent, ConfigurationScope, Event, ExtensionContext } from 'vscode'; +import { ConfigurationTarget, EventEmitter, workspace } from 'vscode'; +import type { Config } from '../config'; +import { areEqual } from './object'; + +const configPrefix = 'gitlens'; + +interface ConfigurationOverrides { + get(section: T, value: ConfigPathValue): ConfigPathValue; + getAll(config: Config): Config; + onChange(e: ConfigurationChangeEvent): ConfigurationChangeEvent; +} + +export class Configuration { + static configure(context: ExtensionContext): void { + context.subscriptions.push( + // eslint-disable-next-line @typescript-eslint/no-use-before-define + workspace.onDidChangeConfiguration(configuration.onConfigurationChanged, configuration), + ); + } + + private _onDidChange = new EventEmitter(); + get onDidChange(): Event { + return this._onDidChange.event; + } + + private _onDidChangeAny = new EventEmitter(); + get onDidChangeAny(): Event { + return this._onDidChangeAny.event; + } + + private _onWillChange = new EventEmitter(); + get onWillChange(): Event { + return this._onWillChange.event; + } + + private onConfigurationChanged(e: ConfigurationChangeEvent) { + if (!e.affectsConfiguration(configPrefix)) { + this._onDidChangeAny.fire(e); + + return; + } + + this._onWillChange.fire(e); + + if (this._overrides?.onChange != null) { + e = this._overrides.onChange(e); + } + + this._onDidChangeAny.fire(e); + this._onDidChange.fire(e); + } + + private _overrides: Partial | undefined; + + applyOverrides(overrides: ConfigurationOverrides): void { + this._overrides = overrides; + } + + clearOverrides(): void { + if (this._overrides == null) return; + + // Don't clear the "onChange" override as we need to keep it until the stack unwinds (so the the event propagates with the override) + this._overrides.get = undefined; + this._overrides.getAll = undefined; + queueMicrotask(() => (this._overrides = undefined)); + } + + get(section: T, scope?: ConfigurationScope | null): ConfigPathValue; + get( + section: T, + scope: ConfigurationScope | null | undefined, + defaultValue: NonNullable>, + ): NonNullable>; + get( + section: T, + scope?: ConfigurationScope | null, + defaultValue?: NonNullable>, + ): ConfigPathValue { + const value = + defaultValue === undefined + ? workspace.getConfiguration(configPrefix, scope).get>(section)! + : workspace.getConfiguration(configPrefix, scope).get>(section, defaultValue)!; + return this._overrides?.get == null ? value : this._overrides.get(section, value); + } + + getAll(skipOverrides?: boolean): Config { + const config = workspace.getConfiguration().get(configPrefix)!; + return skipOverrides || this._overrides?.getAll == null ? config : this._overrides.getAll(config); + } + + getAny(section: string, scope?: ConfigurationScope | null): T | undefined; + getAny(section: string, scope: ConfigurationScope | null | undefined, defaultValue: T): T; + getAny(section: string, scope?: ConfigurationScope | null, defaultValue?: T): T | undefined { + return defaultValue === undefined + ? workspace.getConfiguration(undefined, scope).get(section) + : workspace.getConfiguration(undefined, scope).get(section, defaultValue); + } + + changed( + e: ConfigurationChangeEvent | undefined, + section: T | T[], + scope?: ConfigurationScope | null | undefined, + ): boolean { + if (e == null) return true; + + return Array.isArray(section) + ? section.some(s => e.affectsConfiguration(`${configPrefix}.${s}`, scope!)) + : e.affectsConfiguration(`${configPrefix}.${section}`, scope!); + } + + inspect>(section: T, scope?: ConfigurationScope | null) { + return workspace + .getConfiguration(configPrefix, scope) + .inspect(section === undefined ? configPrefix : section); + } + + inspectAny(section: string, scope?: ConfigurationScope | null) { + return workspace.getConfiguration(undefined, scope).inspect(section); + } + + isUnset(section: T, scope?: ConfigurationScope | null): boolean { + const inspect = this.inspect(section, scope)!; + if (inspect.workspaceFolderValue !== undefined) return false; + if (inspect.workspaceValue !== undefined) return false; + if (inspect.globalValue !== undefined) return false; + + return true; + } + + async migrate( + from: string, + to: T, + options: { fallbackValue?: ConfigPathValue; migrationFn?(value: any): ConfigPathValue }, + ): Promise { + const inspection = this.inspect(from as any); + if (inspection === undefined) return false; + + let migrated = false; + if (inspection.globalValue !== undefined) { + await this.update( + to, + options.migrationFn != null ? options.migrationFn(inspection.globalValue) : inspection.globalValue, + ConfigurationTarget.Global, + ); + migrated = true; + // Can't delete the old setting currently because it errors with `Unable to write to User Settings because is not a registered configuration` + // if (from !== to) { + // try { + // await this.update(from, undefined, ConfigurationTarget.Global); + // } + // catch { } + // } + } + + if (inspection.workspaceValue !== undefined) { + await this.update( + to, + options.migrationFn != null + ? options.migrationFn(inspection.workspaceValue) + : inspection.workspaceValue, + ConfigurationTarget.Workspace, + ); + migrated = true; + // Can't delete the old setting currently because it errors with `Unable to write to User Settings because is not a registered configuration` + // if (from !== to) { + // try { + // await this.update(from, undefined, ConfigurationTarget.Workspace); + // } + // catch { } + // } + } + + if (inspection.workspaceFolderValue !== undefined) { + await this.update( + to, + options.migrationFn != null + ? options.migrationFn(inspection.workspaceFolderValue) + : inspection.workspaceFolderValue, + ConfigurationTarget.WorkspaceFolder, + ); + migrated = true; + // Can't delete the old setting currently because it errors with `Unable to write to User Settings because is not a registered configuration` + // if (from !== to) { + // try { + // await this.update(from, undefined, ConfigurationTarget.WorkspaceFolder); + // } + // catch { } + // } + } + + if (!migrated && options.fallbackValue !== undefined) { + await this.update(to, options.fallbackValue, ConfigurationTarget.Global); + migrated = true; + } + + return migrated; + } + + async migrateIfMissing( + from: string, + to: T, + options: { migrationFn?(value: any): ConfigPathValue }, + ): Promise { + const fromInspection = this.inspect(from as any); + if (fromInspection === undefined) return; + + const toInspection = this.inspect(to); + if (fromInspection.globalValue !== undefined) { + if (toInspection === undefined || toInspection.globalValue === undefined) { + await this.update( + to, + options.migrationFn != null + ? options.migrationFn(fromInspection.globalValue) + : fromInspection.globalValue, + ConfigurationTarget.Global, + ); + // Can't delete the old setting currently because it errors with `Unable to write to User Settings because is not a registered configuration` + // if (from !== to) { + // try { + // await this.update(from, undefined, ConfigurationTarget.Global); + // } + // catch { } + // } + } + } + + if (fromInspection.workspaceValue !== undefined) { + if (toInspection === undefined || toInspection.workspaceValue === undefined) { + await this.update( + to, + options.migrationFn != null + ? options.migrationFn(fromInspection.workspaceValue) + : fromInspection.workspaceValue, + ConfigurationTarget.Workspace, + ); + // Can't delete the old setting currently because it errors with `Unable to write to User Settings because is not a registered configuration` + // if (from !== to) { + // try { + // await this.update(from, undefined, ConfigurationTarget.Workspace); + // } + // catch { } + // } + } + } + + if (fromInspection.workspaceFolderValue !== undefined) { + if (toInspection === undefined || toInspection.workspaceFolderValue === undefined) { + await this.update( + to, + options.migrationFn != null + ? options.migrationFn(fromInspection.workspaceFolderValue) + : fromInspection.workspaceFolderValue, + ConfigurationTarget.WorkspaceFolder, + ); + // Can't delete the old setting currently because it errors with `Unable to write to User Settings because is not a registered configuration` + // if (from !== to) { + // try { + // await this.update(from, undefined, ConfigurationTarget.WorkspaceFolder); + // } + // catch { } + // } + } + } + } + + matches(match: T, section: ConfigPath, value: unknown): value is ConfigPathValue { + return match === section; + } + + name(section: T): string { + return section; + } + + update( + section: T, + value: ConfigPathValue | undefined, + target: ConfigurationTarget, + ): Thenable { + return workspace.getConfiguration(configPrefix).update(section, value, target); + } + + updateAny( + section: string, + value: any, + target: ConfigurationTarget, + scope?: ConfigurationScope | null, + ): Thenable { + return workspace + .getConfiguration(undefined, target === ConfigurationTarget.Global ? undefined : scope!) + .update(section, value, target); + } + + updateEffective(section: T, value: ConfigPathValue | undefined): Thenable { + const inspect = this.inspect(section)!; + if (inspect.workspaceFolderValue !== undefined) { + if (value === inspect.workspaceFolderValue) return Promise.resolve(undefined); + + return this.update(section, value, ConfigurationTarget.WorkspaceFolder); + } + + if (inspect.workspaceValue !== undefined) { + if (value === inspect.workspaceValue) return Promise.resolve(undefined); + + return this.update(section, value, ConfigurationTarget.Workspace); + } + + if (inspect.globalValue === value || (inspect.globalValue === undefined && value === inspect.defaultValue)) { + return Promise.resolve(undefined); + } + + return this.update( + section, + areEqual(value, inspect.defaultValue) ? undefined : value, + ConfigurationTarget.Global, + ); + } +} + +export const configuration = new Configuration(); + +type SubPath = Key extends string + ? T[Key] extends Record + ? + | `${Key}.${SubPath> & string}` + | `${Key}.${Exclude & string}` + : never + : never; + +export type Path = SubPath | keyof T; + +export type PathValue> = P extends `${infer Key}.${infer Rest}` + ? Key extends keyof T + ? Rest extends Path + ? PathValue + : never + : never + : P extends keyof T + ? T[P] + : never; + +export type ConfigPath = Path; +export type ConfigPathValue

= PathValue; diff --git a/src/system/decorators/log.ts b/src/system/decorators/log.ts index 2625755..585eb54 100644 --- a/src/system/decorators/log.ts +++ b/src/system/decorators/log.ts @@ -1,10 +1,10 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ import { hrtime } from '@env/hrtime'; -import { LogLevel, slowCallWarningThreshold } from '../../constants'; -import { getLoggableName, Logger } from '../../logger'; -import type { LogScope } from '../../logScope'; -import { clearLogScope, getNextLogScopeId, setLogScope } from '../../logScope'; import { getParameters } from '../function'; +import { getLoggableName, Logger } from '../logger'; +import { LogLevel, slowCallWarningThreshold } from '../logger.constants'; +import type { LogScope } from '../logger.scope'; +import { clearLogScope, getNextLogScopeId, setLogScope } from '../logger.scope'; import { isPromise } from '../promise'; import { getDurationMilliseconds } from '../string'; @@ -89,9 +89,7 @@ export function log any>(options?: LogOptions, deb scoped = true; } - const logFn = (debug ? Logger.debug.bind(Logger) : Logger.log.bind(Logger)) as - | typeof Logger.debug - | typeof Logger.log; + const logFn = debug ? Logger.debug.bind(Logger) : Logger.log.bind(Logger); const warnFn = Logger.warn.bind(Logger); return (target: any, key: string, descriptor: PropertyDescriptor & Record) => { diff --git a/src/system/keyboard.ts b/src/system/keyboard.ts new file mode 100644 index 0000000..f569cb7 --- /dev/null +++ b/src/system/keyboard.ts @@ -0,0 +1,218 @@ +import { Disposable } from 'vscode'; +import { commandPrefix, ContextKeys } from '../constants'; +import { setContext } from '../context'; +import { registerCommand } from './command'; +import { log } from './decorators/log'; +import { Logger } from './logger'; +import { getLogScope } from './logger.scope'; + +export declare interface KeyCommand { + onDidPressKey?(key: Keys): void | Promise; +} + +const keyNoopCommand = Object.create(null) as KeyCommand; +export { keyNoopCommand as KeyNoopCommand }; + +export const keys = [ + 'left', + 'alt+left', + 'ctrl+left', + 'right', + 'alt+right', + 'ctrl+right', + 'alt+,', + 'alt+.', + 'escape', +] as const; +export type Keys = (typeof keys)[number]; + +export type KeyMapping = { [K in Keys]?: KeyCommand | (() => Promise) }; +type IndexableKeyMapping = KeyMapping & { + [index: string]: KeyCommand | (() => Promise) | undefined; +}; + +const mappings: KeyMapping[] = []; + +export class KeyboardScope implements Disposable { + private readonly _mapping: IndexableKeyMapping; + constructor(mapping: KeyMapping) { + this._mapping = mapping; + for (const key in this._mapping) { + this._mapping[key] = this._mapping[key] ?? keyNoopCommand; + } + + mappings.push(this._mapping); + } + + @log({ + args: false, + prefix: context => `${context.prefix}[${mappings.length}]`, + }) + async dispose() { + const index = mappings.indexOf(this._mapping); + + const scope = getLogScope(); + if (scope != null) { + scope.exitDetails = ` \u2022 index=${index}`; + } + + if (index === mappings.length - 1) { + mappings.pop(); + await this.updateKeyCommandsContext(mappings[mappings.length - 1]); + } else { + mappings.splice(index, 1); + } + } + + private _paused = true; + get paused() { + return this._paused; + } + + @log({ + args: false, + prefix: (context, key) => `${context.prefix}[${mappings.length}](${key})`, + }) + async clearKeyCommand(key: Keys) { + const scope = getLogScope(); + + const mapping = mappings[mappings.length - 1]; + if (mapping !== this._mapping || mapping[key] == null) { + if (scope != null) { + scope.exitDetails = ' \u2022 skipped'; + } + + return; + } + + mapping[key] = undefined; + await setContext(`${ContextKeys.KeyPrefix}${key}`, false); + } + + @log({ + args: false, + prefix: context => `${context.prefix}(paused=${context.instance._paused})`, + }) + async pause(keys?: Keys[]) { + if (this._paused) return; + + this._paused = true; + const mapping = (Object.keys(this._mapping) as Keys[]).reduce((accumulator, key) => { + accumulator[key] = keys == null || keys.includes(key) ? undefined : this._mapping[key]; + return accumulator; + }, Object.create(null)); + + await this.updateKeyCommandsContext(mapping); + } + + @log({ + args: false, + prefix: context => `${context.prefix}(paused=${context.instance._paused})`, + }) + async resume() { + if (!this._paused) return; + + this._paused = false; + await this.updateKeyCommandsContext(this._mapping); + } + + async start() { + await this.resume(); + } + + @log({ + args: false, + prefix: (context, key) => `${context.prefix}[${mappings.length}](${key})`, + }) + async setKeyCommand(key: Keys, command: KeyCommand | (() => Promise)) { + const scope = getLogScope(); + + const mapping = mappings[mappings.length - 1]; + if (mapping !== this._mapping) { + if (scope != null) { + scope.exitDetails = ' \u2022 skipped'; + } + + return; + } + + const set = Boolean(mapping[key]); + + mapping[key] = command; + if (!set) { + await setContext(`${ContextKeys.KeyPrefix}${key}`, true); + } + } + + private async updateKeyCommandsContext(mapping: KeyMapping) { + await Promise.all(keys.map(key => setContext(`${ContextKeys.KeyPrefix}${key}`, Boolean(mapping?.[key])))); + } +} + +export class Keyboard implements Disposable { + private readonly _disposable: Disposable; + + constructor() { + const subscriptions = keys.map(key => + registerCommand(`${commandPrefix}.key.${key}`, () => this.execute(key), this), + ); + this._disposable = Disposable.from(...subscriptions); + } + + dispose() { + this._disposable.dispose(); + } + + @log({ + args: false, + prefix: (context, mapping) => + `${context.prefix}[${mappings.length}](${mapping === undefined ? '' : Object.keys(mapping).join(',')})`, + }) + createScope(mapping?: KeyMapping): KeyboardScope { + return new KeyboardScope({ ...mapping }); + } + + @log({ + args: false, + prefix: (context, mapping) => + `${context.prefix}[${mappings.length}](${mapping === undefined ? '' : Object.keys(mapping).join(',')})`, + }) + async beginScope(mapping?: KeyMapping): Promise { + const scope = this.createScope(mapping); + await scope.start(); + return scope; + } + + @log() + async execute(key: Keys): Promise { + const scope = getLogScope(); + + if (!mappings.length) { + if (scope != null) { + scope.exitDetails = ' \u2022 skipped, no mappings'; + } + + return; + } + + try { + const mapping = mappings[mappings.length - 1]; + + let command = mapping[key] as KeyCommand | (() => Promise); + if (typeof command === 'function') { + command = await command(); + } + if (typeof command?.onDidPressKey !== 'function') { + if (scope != null) { + scope.exitDetails = ' \u2022 skipped, no callback'; + } + + return; + } + + await command.onDidPressKey(key); + } catch (ex) { + Logger.error(ex, scope); + } + } +} diff --git a/src/system/logger.constants.ts b/src/system/logger.constants.ts new file mode 100644 index 0000000..6b1c5c0 --- /dev/null +++ b/src/system/logger.constants.ts @@ -0,0 +1,9 @@ +export const slowCallWarningThreshold = 500; + +export const enum LogLevel { + Off = 'off', + Error = 'error', + Warn = 'warn', + Info = 'info', + Debug = 'debug', +} diff --git a/src/system/logger.scope.ts b/src/system/logger.scope.ts new file mode 100644 index 0000000..345ee94 --- /dev/null +++ b/src/system/logger.scope.ts @@ -0,0 +1,41 @@ +const maxSmallIntegerV8 = 2 ** 30; // Max number that can be stored in V8's smis (small integers) + +const scopes = new Map(); +let scopeCounter = 0; + +export interface LogScope { + readonly scopeId?: number; + readonly prefix: string; + exitDetails?: string; +} + +export function clearLogScope(scopeId: number) { + scopes.delete(scopeId); +} + +export function getLogScope(): LogScope | undefined { + return scopes.get(scopeCounter); +} + +export function getNewLogScope(prefix: string): LogScope { + const scopeId = getNextLogScopeId(); + return { + scopeId: scopeId, + prefix: `[${String(scopeId).padStart(5)}] ${prefix}`, + }; +} + +export function getLogScopeId(): number { + return scopeCounter; +} + +export function getNextLogScopeId(): number { + if (scopeCounter === maxSmallIntegerV8) { + scopeCounter = 0; + } + return ++scopeCounter; +} + +export function setLogScope(scopeId: number, scope: LogScope) { + scopes.set(scopeId, scope); +} diff --git a/src/system/logger.ts b/src/system/logger.ts new file mode 100644 index 0000000..5e2b674 --- /dev/null +++ b/src/system/logger.ts @@ -0,0 +1,254 @@ +import { LogLevel } from './logger.constants'; +import type { LogScope } from './logger.scope'; + +const emptyStr = ''; + +const enum OrderedLevel { + Off = 0, + Error = 1, + Warn = 2, + Info = 3, + Debug = 4, +} + +export interface LogChannelProvider { + readonly name: string; + createChannel(name: string): LogChannel; + toLoggable?(o: unknown): string | undefined; +} + +export interface LogChannel { + readonly name: string; + appendLine(value: string): void; + dispose?(): void; + show?(preserveFocus?: boolean): void; +} + +export const Logger = new (class Logger { + private output: LogChannel | undefined; + private provider: LogChannelProvider | undefined; + + configure(provider: LogChannelProvider, logLevel: LogLevel, debugging: boolean = false) { + this.provider = provider; + + this._isDebugging = debugging; + this.logLevel = logLevel; + } + + enabled(level: LogLevel): boolean { + return this.level >= toOrderedLevel(level); + } + + private _isDebugging = false; + get isDebugging() { + return this._isDebugging; + } + + private level: OrderedLevel = OrderedLevel.Off; + private _logLevel: LogLevel = LogLevel.Off; + get logLevel(): LogLevel { + return this._logLevel; + } + set logLevel(value: LogLevel) { + this._logLevel = value; + this.level = toOrderedLevel(this._logLevel); + + if (value === LogLevel.Off) { + this.output?.dispose?.(); + this.output = undefined; + } else { + this.output = this.output ?? this.provider!.createChannel(this.provider!.name); + } + } + + get timestamp(): string { + return `[${new Date().toISOString().replace(/T/, ' ').slice(0, -1)}]`; + } + + debug(message: string, ...params: any[]): void; + debug(scope: LogScope | undefined, message: string, ...params: any[]): void; + debug(scopeOrMessage: LogScope | string | undefined, ...params: any[]): void { + if (this.level < OrderedLevel.Debug && !this.isDebugging) return; + + let message; + if (typeof scopeOrMessage === 'string') { + message = scopeOrMessage; + } else { + message = params.shift(); + + if (scopeOrMessage != null) { + message = `${scopeOrMessage.prefix} ${message ?? emptyStr}`; + } + } + + if (this.isDebugging) { + console.log(this.timestamp, `[${this.provider!.name}]`, message ?? emptyStr, ...params); + } + + if (this.output == null || this.level < OrderedLevel.Debug) return; + this.output.appendLine(`${this.timestamp} ${message ?? emptyStr}${this.toLoggableParams(true, params)}`); + } + + error(ex: Error | unknown, message?: string, ...params: any[]): void; + error(ex: Error | unknown, scope?: LogScope, message?: string, ...params: any[]): void; + error(ex: Error | unknown, scopeOrMessage: LogScope | string | undefined, ...params: any[]): void { + if (this.level < OrderedLevel.Error && !this.isDebugging) return; + + let message; + if (scopeOrMessage == null || typeof scopeOrMessage === 'string') { + message = scopeOrMessage; + } else { + message = `${scopeOrMessage.prefix} ${params.shift() ?? emptyStr}`; + } + + if (message == null) { + const stack = ex instanceof Error ? ex.stack : undefined; + if (stack) { + const match = /.*\s*?at\s(.+?)\s/.exec(stack); + if (match != null) { + message = match[1]; + } + } + } + + if (this.isDebugging) { + console.error(this.timestamp, `[${this.provider!.name}]`, message ?? emptyStr, ...params, ex); + } + + if (this.output == null || this.level < OrderedLevel.Error) return; + this.output.appendLine( + `${this.timestamp} ${message ?? emptyStr}${this.toLoggableParams(false, params)}\n${String(ex)}`, + ); + } + + log(message: string, ...params: any[]): void; + log(scope: LogScope | undefined, message: string, ...params: any[]): void; + log(scopeOrMessage: LogScope | string | undefined, ...params: any[]): void { + if (this.level < OrderedLevel.Info && !this.isDebugging) return; + + let message; + if (typeof scopeOrMessage === 'string') { + message = scopeOrMessage; + } else { + message = params.shift(); + + if (scopeOrMessage != null) { + message = `${scopeOrMessage.prefix} ${message ?? emptyStr}`; + } + } + + if (this.isDebugging) { + console.log(this.timestamp, `[${this.provider!.name}]`, message ?? emptyStr, ...params); + } + + if (this.output == null || this.level < OrderedLevel.Info) return; + this.output.appendLine(`${this.timestamp} ${message ?? emptyStr}${this.toLoggableParams(false, params)}`); + } + + warn(message: string, ...params: any[]): void; + warn(scope: LogScope | undefined, message: string, ...params: any[]): void; + warn(scopeOrMessage: LogScope | string | undefined, ...params: any[]): void { + if (this.level < OrderedLevel.Warn && !this.isDebugging) return; + + let message; + if (typeof scopeOrMessage === 'string') { + message = scopeOrMessage; + } else { + message = params.shift(); + + if (scopeOrMessage != null) { + message = `${scopeOrMessage.prefix} ${message ?? emptyStr}`; + } + } + + if (this.isDebugging) { + console.warn(this.timestamp, `[${this.provider!.name}]`, message ?? emptyStr, ...params); + } + + if (this.output == null || this.level < OrderedLevel.Warn) return; + this.output.appendLine(`${this.timestamp} ${message ?? emptyStr}${this.toLoggableParams(false, params)}`); + } + + showOutputChannel(preserveFocus?: boolean): void { + this.output?.show?.(preserveFocus); + } + + toLoggable(o: any, sanitize?: ((key: string, value: any) => any) | undefined) { + if (typeof o !== 'object') return String(o); + + const loggable = this.provider!.toLoggable?.(o); + if (loggable != null) return loggable; + + try { + return JSON.stringify(o, sanitize); + } catch { + return ''; + } + } + + private toLoggableParams(debugOnly: boolean, params: any[]) { + if (params.length === 0 || (debugOnly && this.level < OrderedLevel.Debug && !this.isDebugging)) { + return emptyStr; + } + + const loggableParams = params.map(p => this.toLoggable(p)).join(', '); + return loggableParams.length !== 0 ? ` \u2014 ${loggableParams}` : emptyStr; + } +})(); + +function toOrderedLevel(logLevel: LogLevel): OrderedLevel { + switch (logLevel) { + case LogLevel.Off: + return OrderedLevel.Off; + case LogLevel.Error: + return OrderedLevel.Error; + case LogLevel.Warn: + return OrderedLevel.Warn; + case LogLevel.Info: + return OrderedLevel.Info; + case LogLevel.Debug: + return OrderedLevel.Debug; + default: + return OrderedLevel.Off; + } +} + +export function getLoggableName(instance: Function | object) { + let name: string; + if (typeof instance === 'function') { + if (instance.prototype?.constructor == null) return instance.name; + + name = instance.prototype.constructor.name ?? emptyStr; + } else { + name = instance.constructor?.name ?? emptyStr; + } + + // Strip webpack module name (since I never name classes with an _) + const index = name.indexOf('_'); + return index === -1 ? name : name.substr(index + 1); +} + +export interface LogProvider { + enabled(logLevel: LogLevel): boolean; + log(logLevel: LogLevel, scope: LogScope | undefined, message: string, ...params: any[]): void; +} + +export const defaultLogProvider: LogProvider = { + enabled: (logLevel: LogLevel) => Logger.enabled(logLevel), + log: (logLevel: LogLevel, scope: LogScope | undefined, message: string, ...params: any[]) => { + switch (logLevel) { + case LogLevel.Error: + Logger.error('', scope, message, ...params); + break; + case LogLevel.Warn: + Logger.warn(scope, message, ...params); + break; + case LogLevel.Info: + Logger.log(scope, message, ...params); + break; + default: + Logger.debug(scope, message, ...params); + break; + } + }, +}; diff --git a/src/system/stopwatch.ts b/src/system/stopwatch.ts index fadc4d3..fe72364 100644 --- a/src/system/stopwatch.ts +++ b/src/system/stopwatch.ts @@ -1,9 +1,10 @@ import { hrtime } from '@env/hrtime'; -import { GlyphChars, LogLevel } from '../constants'; -import type { LogProvider } from '../logger'; -import { defaultLogProvider } from '../logger'; -import type { LogScope } from '../logScope'; -import { getNextLogScopeId } from '../logScope'; +import { GlyphChars } from '../constants'; +import type { LogProvider } from './logger'; +import { defaultLogProvider } from './logger'; +import { LogLevel } from './logger.constants'; +import type { LogScope } from './logger.scope'; +import { getNextLogScopeId } from './logger.scope'; type StopwatchLogOptions = { message?: string; suffix?: string }; type StopwatchOptions = { diff --git a/src/system/utils.ts b/src/system/utils.ts index 18f79d7..d4e9e9a 100644 --- a/src/system/utils.ts +++ b/src/system/utils.ts @@ -1,10 +1,10 @@ import type { ColorTheme, TextDocument, TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; import { ColorThemeKind, env, ViewColumn, window, workspace } from 'vscode'; -import { configuration } from '../configuration'; import { CoreCommands, ImageMimetypes, Schemes } from '../constants'; import { isGitUri } from '../git/gitUri'; -import { Logger } from '../logger'; import { executeCoreCommand } from './command'; +import { configuration } from './configuration'; +import { Logger } from './logger'; import { extname } from './path'; export function findTextDocument(uri: Uri): TextDocument | undefined { diff --git a/src/telemetry/telemetry.ts b/src/telemetry/telemetry.ts index 07cd575..64a2acd 100644 --- a/src/telemetry/telemetry.ts +++ b/src/telemetry/telemetry.ts @@ -3,8 +3,8 @@ import type { Disposable } from 'vscode'; import { version as codeVersion, env } from 'vscode'; import { getProxyAgent } from '@env/fetch'; import { getPlatform } from '@env/platform'; -import { configuration } from '../configuration'; import type { Container } from '../container'; +import { configuration } from '../system/configuration'; export interface TelemetryContext { env: string; diff --git a/src/telemetry/usageTracker.ts b/src/telemetry/usageTracker.ts new file mode 100644 index 0000000..9aac5ca --- /dev/null +++ b/src/telemetry/usageTracker.ts @@ -0,0 +1,104 @@ +import type { Disposable, Event } from 'vscode'; +import { EventEmitter } from 'vscode'; +import type { Container } from '../container'; +import type { Storage } from '../storage'; +import { updateRecordValue } from '../system/object'; + +export interface TrackedUsage { + count: number; + firstUsedAt: number; + lastUsedAt: number; +} + +export type TrackedUsageFeatures = + | 'branchesView' + | 'commitDetailsView' + | 'commitsView' + | 'contributorsView' + | 'fileHistoryView' + | 'graphWebview' + | 'homeView' + | 'lineHistoryView' + | 'rebaseEditor' + | 'remotesView' + | 'repositoriesView' + | 'stashesView' + | 'settingsWebview' + | 'searchAndCompareView' + | 'tagsView' + | 'timelineWebview' + | 'timelineView' + | 'welcomeWebview' + | 'workspaceView' + | 'focusWebview'; +export type TrackedUsageKeys = `${TrackedUsageFeatures}:shown`; + +export type UsageChangeEvent = { + /** + * The key of the action/event/feature who's usage was tracked + */ + readonly key: TrackedUsageKeys; + readonly usage?: TrackedUsage; +}; + +export class UsageTracker implements Disposable { + private _onDidChange = new EventEmitter(); + get onDidChange(): Event { + return this._onDidChange.event; + } + + constructor(private readonly container: Container, private readonly storage: Storage) {} + + dispose(): void {} + + get(key: TrackedUsageKeys): TrackedUsage | undefined { + return this.storage.get('usages')?.[key]; + } + + async reset(key?: TrackedUsageKeys): Promise { + let usages = this.storage.get('usages'); + if (usages == null) return; + + if (key == null) { + await this.storage.delete('usages'); + this._onDidChange.fire(undefined); + + return; + } + + usages = updateRecordValue(usages, key, undefined); + + await this.storage.store('usages', usages); + this._onDidChange.fire({ key: key, usage: undefined }); + } + + async track(key: TrackedUsageKeys): Promise { + let usages = this.storage.get('usages'); + if (usages == null) { + usages = Object.create(null) as NonNullable; + } + + const usedAt = Date.now(); + + let usage = usages[key]; + if (usage == null) { + usage = { + count: 0, + firstUsedAt: usedAt, + lastUsedAt: usedAt, + }; + usages[key] = usage; + } else { + if (usage.count !== Number.MAX_SAFE_INTEGER) { + usage.count++; + } + usage.lastUsedAt = usedAt; + } + + this.container.telemetry.sendEvent('usage/track', { 'usage.key': key, 'usage.count': usage.count }); + + await this.storage.store('usages', usages); + + this._onDidChange.fire({ key: key, usage: usage }); + } +} diff --git a/src/terminal.ts b/src/terminal.ts index dddf4d9..498c3df 100644 --- a/src/terminal.ts +++ b/src/terminal.ts @@ -1,7 +1,7 @@ import type { Disposable, Terminal } from 'vscode'; import { window } from 'vscode'; -import { configuration } from './configuration'; import { Container } from './container'; +import { configuration } from './system/configuration'; import { getEditorCommand } from './system/utils'; let _terminal: Terminal | undefined; diff --git a/src/terminal/linkProvider.ts b/src/terminal/linkProvider.ts index 7f3eb16..1e061fe 100644 --- a/src/terminal/linkProvider.ts +++ b/src/terminal/linkProvider.ts @@ -6,7 +6,6 @@ import type { ShowQuickBranchHistoryCommandArgs, ShowQuickCommitCommandArgs, } from '../commands'; -import { configuration } from '../configuration'; import { Commands } from '../constants'; import type { Container } from '../container'; import type { PagedResult } from '../git/gitProvider'; @@ -14,6 +13,7 @@ import type { GitBranch } from '../git/models/branch'; import { getBranchNameWithoutRemote } from '../git/models/branch'; import { createReference } from '../git/models/reference'; import type { GitTag } from '../git/models/tag'; +import { configuration } from '../system/configuration'; const commandsRegexShared = /\b(g(?:it)?\b\s*)\b(branch|checkout|cherry-pick|fetch|grep|log|merge|pull|push|rebase|reset|revert|show|stash|status|tag)\b/gi; diff --git a/src/trackers/documentTracker.ts b/src/trackers/documentTracker.ts index f17e431..2f93aa1 100644 --- a/src/trackers/documentTracker.ts +++ b/src/trackers/documentTracker.ts @@ -10,7 +10,6 @@ import type { TextLine, } from 'vscode'; import { Disposable, EndOfLine, env, EventEmitter, Uri, window, workspace } from 'vscode'; -import { configuration } from '../configuration'; import { ContextKeys } from '../constants'; import type { Container } from '../container'; import { setContext } from '../context'; @@ -19,6 +18,7 @@ import type { GitUri } from '../git/gitUri'; import { isGitUri } from '../git/gitUri'; import type { RepositoryChangeEvent } from '../git/models/repository'; import { RepositoryChange, RepositoryChangeComparisonMode } from '../git/models/repository'; +import { configuration } from '../system/configuration'; import { debug } from '../system/decorators/log'; import { once } from '../system/event'; import type { Deferrable } from '../system/function'; diff --git a/src/trackers/gitLineTracker.ts b/src/trackers/gitLineTracker.ts index e039dcb..8fedc98 100644 --- a/src/trackers/gitLineTracker.ts +++ b/src/trackers/gitLineTracker.ts @@ -1,11 +1,11 @@ import type { TextEditor } from 'vscode'; import { Disposable } from 'vscode'; -import { configuration } from '../configuration'; import { GlyphChars } from '../constants'; import type { Container } from '../container'; import type { GitCommit } from '../git/models/commit'; -import { getLogScope } from '../logScope'; +import { configuration } from '../system/configuration'; import { debug } from '../system/decorators/log'; +import { getLogScope } from '../system/logger.scope'; import type { DocumentBlameStateChangeEvent, DocumentContentChangeEvent, diff --git a/src/trackers/lineTracker.ts b/src/trackers/lineTracker.ts index c0fdb9f..580b94e 100644 --- a/src/trackers/lineTracker.ts +++ b/src/trackers/lineTracker.ts @@ -1,10 +1,10 @@ import type { Event, Selection, TextEditor, TextEditorSelectionChangeEvent } from 'vscode'; import { Disposable, EventEmitter, window } from 'vscode'; -import { Logger } from '../logger'; -import { getLogScope } from '../logScope'; import { debug } from '../system/decorators/log'; import type { Deferrable } from '../system/function'; import { debounce } from '../system/function'; +import { Logger } from '../system/logger'; +import { getLogScope } from '../system/logger.scope'; import { isTextEditor } from '../system/utils'; export interface LinesChangeEvent { diff --git a/src/trackers/trackedDocument.ts b/src/trackers/trackedDocument.ts index 3abd035..3dfb839 100644 --- a/src/trackers/trackedDocument.ts +++ b/src/trackers/trackedDocument.ts @@ -5,9 +5,9 @@ import type { Container } from '../container'; import { setContext } from '../context'; import { GitUri } from '../git/gitUri'; import { deletedOrMissing } from '../git/models/constants'; -import { Logger } from '../logger'; import type { Deferrable } from '../system/function'; import { debounce } from '../system/function'; +import { Logger } from '../system/logger'; import { getEditorIfActive, isActiveDocument } from '../system/utils'; export interface DocumentBlameStateChangeEvent { diff --git a/src/uris/deepLinks/deepLinkService.ts b/src/uris/deepLinks/deepLinkService.ts index 2863ee3..3ef7832 100644 --- a/src/uris/deepLinks/deepLinkService.ts +++ b/src/uris/deepLinks/deepLinkService.ts @@ -1,5 +1,4 @@ import { Disposable, env, ProgressLocation, Uri, window, workspace } from 'vscode'; -import { configuration } from '../../configuration'; import { Commands } from '../../constants'; import type { Container } from '../../container'; import { getBranchNameWithoutRemote } from '../../git/models/branch'; @@ -7,11 +6,12 @@ import type { GitReference } from '../../git/models/reference'; import { createReference } from '../../git/models/reference'; import type { GitRemote } from '../../git/models/remote'; import { parseGitRemoteUrl } from '../../git/parsers/remoteParser'; -import { Logger } from '../../logger'; import type { ShowInCommitGraphCommandArgs } from '../../plus/webviews/graph/graphWebview'; import type { StoredDeepLinkContext } from '../../storage'; import { executeCommand } from '../../system/command'; +import { configuration } from '../../system/configuration'; import { once } from '../../system/event'; +import { Logger } from '../../system/logger'; import { openWorkspace, OpenWorkspaceLocation } from '../../system/utils'; import type { DeepLink, DeepLinkServiceContext } from './deepLink'; import { diff --git a/src/usageTracker.ts b/src/usageTracker.ts deleted file mode 100644 index 928da3d..0000000 --- a/src/usageTracker.ts +++ /dev/null @@ -1,104 +0,0 @@ -import type { Disposable, Event } from 'vscode'; -import { EventEmitter } from 'vscode'; -import type { Container } from './container'; -import type { Storage } from './storage'; -import { updateRecordValue } from './system/object'; - -export interface TrackedUsage { - count: number; - firstUsedAt: number; - lastUsedAt: number; -} - -export type TrackedUsageFeatures = - | 'branchesView' - | 'commitDetailsView' - | 'commitsView' - | 'contributorsView' - | 'fileHistoryView' - | 'graphWebview' - | 'homeView' - | 'lineHistoryView' - | 'rebaseEditor' - | 'remotesView' - | 'repositoriesView' - | 'stashesView' - | 'settingsWebview' - | 'searchAndCompareView' - | 'tagsView' - | 'timelineWebview' - | 'timelineView' - | 'welcomeWebview' - | 'workspaceView' - | 'focusWebview'; -export type TrackedUsageKeys = `${TrackedUsageFeatures}:shown`; - -export type UsageChangeEvent = { - /** - * The key of the action/event/feature who's usage was tracked - */ - readonly key: TrackedUsageKeys; - readonly usage?: TrackedUsage; -}; - -export class UsageTracker implements Disposable { - private _onDidChange = new EventEmitter(); - get onDidChange(): Event { - return this._onDidChange.event; - } - - constructor(private readonly container: Container, private readonly storage: Storage) {} - - dispose(): void {} - - get(key: TrackedUsageKeys): TrackedUsage | undefined { - return this.storage.get('usages')?.[key]; - } - - async reset(key?: TrackedUsageKeys): Promise { - let usages = this.storage.get('usages'); - if (usages == null) return; - - if (key == null) { - await this.storage.delete('usages'); - this._onDidChange.fire(undefined); - - return; - } - - usages = updateRecordValue(usages, key, undefined); - - await this.storage.store('usages', usages); - this._onDidChange.fire({ key: key, usage: undefined }); - } - - async track(key: TrackedUsageKeys): Promise { - let usages = this.storage.get('usages'); - if (usages == null) { - usages = Object.create(null) as NonNullable; - } - - const usedAt = Date.now(); - - let usage = usages[key]; - if (usage == null) { - usage = { - count: 0, - firstUsedAt: usedAt, - lastUsedAt: usedAt, - }; - usages[key] = usage; - } else { - if (usage.count !== Number.MAX_SAFE_INTEGER) { - usage.count++; - } - usage.lastUsedAt = usedAt; - } - - this.container.telemetry.sendEvent('usage/track', { 'usage.key': key, 'usage.count': usage.count }); - - await this.storage.store('usages', usages); - - this._onDidChange.fire({ key: key, usage: usage }); - } -} diff --git a/src/views/branchesView.ts b/src/views/branchesView.ts index 0331add..7edbc1a 100644 --- a/src/views/branchesView.ts +++ b/src/views/branchesView.ts @@ -1,7 +1,7 @@ import type { CancellationToken, ConfigurationChangeEvent, Disposable } from 'vscode'; import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; -import type { BranchesViewConfig } from '../configuration'; -import { configuration, ViewBranchesLayout, ViewFilesLayout, ViewShowBranchComparison } from '../configuration'; +import type { BranchesViewConfig } from '../config'; +import { ViewBranchesLayout, ViewFilesLayout, ViewShowBranchComparison } from '../config'; import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; @@ -12,6 +12,7 @@ import { getReferenceLabel } from '../git/models/reference'; import type { RepositoryChangeEvent } from '../git/models/repository'; import { RepositoryChange, RepositoryChangeComparisonMode } from '../git/models/repository'; import { executeCommand } from '../system/command'; +import { configuration } from '../system/configuration'; import { gate } from '../system/decorators/gate'; import { BranchesNode } from './nodes/branchesNode'; import { BranchNode } from './nodes/branchNode'; diff --git a/src/views/commitsView.ts b/src/views/commitsView.ts index 636da30..f4e259e 100644 --- a/src/views/commitsView.ts +++ b/src/views/commitsView.ts @@ -5,8 +5,8 @@ import type { TreeViewVisibilityChangeEvent, } from 'vscode'; import { Disposable, ProgressLocation, ThemeIcon, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; -import type { CommitsViewConfig } from '../configuration'; -import { configuration, ViewFilesLayout, ViewShowBranchComparison } from '../configuration'; +import type { CommitsViewConfig } from '../config'; +import { ViewFilesLayout, ViewShowBranchComparison } from '../config'; import { Commands, ContextKeys, GlyphChars } from '../constants'; import type { Container } from '../container'; import { setContext } from '../context'; @@ -18,10 +18,11 @@ import { getReferenceLabel } from '../git/models/reference'; import type { RepositoryChangeEvent } from '../git/models/repository'; import { Repository, RepositoryChange, RepositoryChangeComparisonMode } from '../git/models/repository'; import { executeCommand } from '../system/command'; +import { configuration } from '../system/configuration'; import { gate } from '../system/decorators/gate'; import { debug } from '../system/decorators/log'; import { disposableInterval } from '../system/function'; -import type { UsageChangeEvent } from '../usageTracker'; +import type { UsageChangeEvent } from '../telemetry/usageTracker'; import { BranchNode } from './nodes/branchNode'; import { BranchTrackingStatusNode } from './nodes/branchTrackingStatusNode'; import { CommitFileNode } from './nodes/commitFileNode'; diff --git a/src/views/contributorsView.ts b/src/views/contributorsView.ts index 537535a..48616c3 100644 --- a/src/views/contributorsView.ts +++ b/src/views/contributorsView.ts @@ -1,8 +1,8 @@ import type { CancellationToken, ConfigurationChangeEvent } from 'vscode'; import { Disposable, ProgressLocation, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import { onDidFetchAvatar } from '../avatars'; -import type { ContributorsViewConfig } from '../configuration'; -import { configuration, ViewFilesLayout } from '../configuration'; +import type { ContributorsViewConfig } from '../config'; +import { ViewFilesLayout } from '../config'; import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; @@ -10,6 +10,7 @@ import type { GitContributor } from '../git/models/contributor'; import type { RepositoryChangeEvent } from '../git/models/repository'; import { RepositoryChange, RepositoryChangeComparisonMode } from '../git/models/repository'; import { executeCommand } from '../system/command'; +import { configuration } from '../system/configuration'; import { gate } from '../system/decorators/gate'; import { debug } from '../system/decorators/log'; import { ContributorNode } from './nodes/contributorNode'; diff --git a/src/views/fileHistoryView.ts b/src/views/fileHistoryView.ts index f06a793..29f7bc4 100644 --- a/src/views/fileHistoryView.ts +++ b/src/views/fileHistoryView.ts @@ -1,11 +1,11 @@ import type { ConfigurationChangeEvent, Disposable } from 'vscode'; -import type { FileHistoryViewConfig } from '../configuration'; -import { configuration } from '../configuration'; +import type { FileHistoryViewConfig } from '../config'; import { Commands, ContextKeys } from '../constants'; import type { Container } from '../container'; import { setContext } from '../context'; import type { GitUri } from '../git/gitUri'; import { executeCommand } from '../system/command'; +import { configuration } from '../system/configuration'; import { FileHistoryTrackerNode } from './nodes/fileHistoryTrackerNode'; import { LineHistoryTrackerNode } from './nodes/lineHistoryTrackerNode'; import { ViewBase } from './viewBase'; diff --git a/src/views/lineHistoryView.ts b/src/views/lineHistoryView.ts index 3608a8a..9f32f7a 100644 --- a/src/views/lineHistoryView.ts +++ b/src/views/lineHistoryView.ts @@ -1,10 +1,10 @@ import type { ConfigurationChangeEvent, Disposable } from 'vscode'; -import type { LineHistoryViewConfig } from '../configuration'; -import { configuration } from '../configuration'; +import type { LineHistoryViewConfig } from '../config'; import { Commands, ContextKeys } from '../constants'; import type { Container } from '../container'; import { setContext } from '../context'; import { executeCommand } from '../system/command'; +import { configuration } from '../system/configuration'; import { LineHistoryTrackerNode } from './nodes/lineHistoryTrackerNode'; import { ViewBase } from './viewBase'; import { registerViewCommand } from './viewCommands'; diff --git a/src/views/nodes/branchNode.ts b/src/views/nodes/branchNode.ts index 0c55b43..dd287d7 100644 --- a/src/views/nodes/branchNode.ts +++ b/src/views/nodes/branchNode.ts @@ -1,6 +1,6 @@ import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, window } from 'vscode'; -import type { ViewShowBranchComparison } from '../../configuration'; -import { ViewBranchesLayout } from '../../configuration'; +import type { ViewShowBranchComparison } from '../../config'; +import { ViewBranchesLayout } from '../../config'; import { Colors, ContextKeys, GlyphChars } from '../../constants'; import { getContext } from '../../context'; import type { GitUri } from '../../git/gitUri'; diff --git a/src/views/nodes/branchTrackingStatusFilesNode.ts b/src/views/nodes/branchTrackingStatusFilesNode.ts index d16fa7f..816582e 100644 --- a/src/views/nodes/branchTrackingStatusFilesNode.ts +++ b/src/views/nodes/branchTrackingStatusFilesNode.ts @@ -1,5 +1,5 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode'; -import { ViewFilesLayout } from '../../configuration'; +import { ViewFilesLayout } from '../../config'; import { GitUri } from '../../git/gitUri'; import type { GitBranch } from '../../git/models/branch'; import type { GitFileWithCommit } from '../../git/models/file'; diff --git a/src/views/nodes/branchesNode.ts b/src/views/nodes/branchesNode.ts index 55dadf4..fd16073 100644 --- a/src/views/nodes/branchesNode.ts +++ b/src/views/nodes/branchesNode.ts @@ -1,5 +1,5 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; -import { ViewBranchesLayout } from '../../configuration'; +import { ViewBranchesLayout } from '../../config'; import { GitUri } from '../../git/gitUri'; import type { Repository } from '../../git/models/repository'; import { makeHierarchical } from '../../system/array'; diff --git a/src/views/nodes/commitNode.ts b/src/views/nodes/commitNode.ts index 40cd653..5eb1eec 100644 --- a/src/views/nodes/commitNode.ts +++ b/src/views/nodes/commitNode.ts @@ -1,7 +1,7 @@ import type { Command } from 'vscode'; import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import type { DiffWithPreviousCommandArgs } from '../../commands'; -import { configuration, ViewFilesLayout } from '../../configuration'; +import { ViewFilesLayout } from '../../config'; import { Colors, Commands, ContextKeys } from '../../constants'; import { getContext } from '../../context'; import { CommitFormatter } from '../../git/formatters/commitFormatter'; @@ -12,6 +12,7 @@ import type { GitRevisionReference } from '../../git/models/reference'; import type { GitRemote } from '../../git/models/remote'; import type { RichRemoteProvider } from '../../git/remotes/richRemoteProvider'; import { makeHierarchical } from '../../system/array'; +import { configuration } from '../../system/configuration'; import { gate } from '../../system/decorators/gate'; import { joinPaths, normalizePath } from '../../system/path'; import type { Deferred } from '../../system/promise'; diff --git a/src/views/nodes/common.ts b/src/views/nodes/common.ts index 6e21e35..c9d8384 100644 --- a/src/views/nodes/common.ts +++ b/src/views/nodes/common.ts @@ -1,8 +1,8 @@ import type { Command, ThemeIcon, Uri } from 'vscode'; import { TreeItem, TreeItemCollapsibleState } from 'vscode'; -import { configuration } from '../../configuration'; import { GlyphChars } from '../../constants'; import { unknownGitUri } from '../../git/gitUri'; +import { configuration } from '../../system/configuration'; import type { View } from '../viewBase'; import type { PageableViewNode } from './viewNode'; import { ContextValues, ViewNode } from './viewNode'; diff --git a/src/views/nodes/compareBranchNode.ts b/src/views/nodes/compareBranchNode.ts index edf1b5f..23e8292 100644 --- a/src/views/nodes/compareBranchNode.ts +++ b/src/views/nodes/compareBranchNode.ts @@ -1,5 +1,5 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; -import { ViewShowBranchComparison } from '../../configuration'; +import { ViewShowBranchComparison } from '../../config'; import { GlyphChars } from '../../constants'; import type { GitUri } from '../../git/gitUri'; import type { GitBranch } from '../../git/models/branch'; diff --git a/src/views/nodes/contributorNode.ts b/src/views/nodes/contributorNode.ts index 939bb0f..163d8a0 100644 --- a/src/views/nodes/contributorNode.ts +++ b/src/views/nodes/contributorNode.ts @@ -1,10 +1,10 @@ import { MarkdownString, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import { getPresenceDataUri } from '../../avatars'; -import { configuration } from '../../configuration'; import { GlyphChars } from '../../constants'; import type { GitUri } from '../../git/gitUri'; import type { GitContributor } from '../../git/models/contributor'; import type { GitLog } from '../../git/models/log'; +import { configuration } from '../../system/configuration'; import { gate } from '../../system/decorators/gate'; import { debug } from '../../system/decorators/log'; import { map } from '../../system/iterable'; diff --git a/src/views/nodes/contributorsNode.ts b/src/views/nodes/contributorsNode.ts index 5823af9..5edb2b4 100644 --- a/src/views/nodes/contributorsNode.ts +++ b/src/views/nodes/contributorsNode.ts @@ -1,8 +1,8 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; -import { configuration } from '../../configuration'; import type { GitUri } from '../../git/gitUri'; import { GitContributor } from '../../git/models/contributor'; import type { Repository } from '../../git/models/repository'; +import { configuration } from '../../system/configuration'; import { gate } from '../../system/decorators/gate'; import { debug } from '../../system/decorators/log'; import { timeout } from '../../system/decorators/timeout'; diff --git a/src/views/nodes/fileHistoryNode.ts b/src/views/nodes/fileHistoryNode.ts index 4ad2793..815ecc0 100644 --- a/src/views/nodes/fileHistoryNode.ts +++ b/src/views/nodes/fileHistoryNode.ts @@ -1,16 +1,16 @@ import { Disposable, TreeItem, TreeItemCollapsibleState, Uri, window } from 'vscode'; -import { configuration } from '../../configuration'; import type { GitUri } from '../../git/gitUri'; import type { GitBranch } from '../../git/models/branch'; import { deletedOrMissing } from '../../git/models/constants'; import type { GitLog } from '../../git/models/log'; import type { RepositoryChangeEvent, RepositoryFileSystemChangeEvent } from '../../git/models/repository'; import { RepositoryChange, RepositoryChangeComparisonMode } from '../../git/models/repository'; -import { Logger } from '../../logger'; +import { configuration } from '../../system/configuration'; import { gate } from '../../system/decorators/gate'; import { debug } from '../../system/decorators/log'; import { memoize } from '../../system/decorators/memoize'; import { filterMap, flatMap, map, uniqueBy } from '../../system/iterable'; +import { Logger } from '../../system/logger'; import { basename } from '../../system/path'; import type { FileHistoryView } from '../fileHistoryView'; import { CommitNode } from './commitNode'; diff --git a/src/views/nodes/fileHistoryTrackerNode.ts b/src/views/nodes/fileHistoryTrackerNode.ts index afba227..195383d 100644 --- a/src/views/nodes/fileHistoryTrackerNode.ts +++ b/src/views/nodes/fileHistoryTrackerNode.ts @@ -1,18 +1,18 @@ import type { TextEditor } from 'vscode'; import { Disposable, FileType, TreeItem, TreeItemCollapsibleState, window, workspace } from 'vscode'; -import { UriComparer } from '../../comparers'; import { ContextKeys } from '../../constants'; import { setContext } from '../../context'; import type { GitCommitish } from '../../git/gitUri'; import { GitUri, unknownGitUri } from '../../git/gitUri'; import { isBranchReference, isSha } from '../../git/models/reference'; -import { Logger } from '../../logger'; -import { getLogScope } from '../../logScope'; import { showReferencePicker } from '../../quickpicks/referencePicker'; +import { UriComparer } from '../../system/comparers'; import { gate } from '../../system/decorators/gate'; import { debug, log } from '../../system/decorators/log'; import type { Deferrable } from '../../system/function'; import { debounce } from '../../system/function'; +import { Logger } from '../../system/logger'; +import { getLogScope } from '../../system/logger.scope'; import { isVirtualUri } from '../../system/utils'; import type { FileHistoryView } from '../fileHistoryView'; import { FileHistoryNode } from './fileHistoryNode'; diff --git a/src/views/nodes/fileRevisionAsCommitNode.ts b/src/views/nodes/fileRevisionAsCommitNode.ts index 78d508d..982b9cd 100644 --- a/src/views/nodes/fileRevisionAsCommitNode.ts +++ b/src/views/nodes/fileRevisionAsCommitNode.ts @@ -1,7 +1,6 @@ import type { Command, Selection } from 'vscode'; import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode'; import type { DiffWithPreviousCommandArgs } from '../../commands'; -import { configuration } from '../../configuration'; import { Colors, Commands } from '../../constants'; import { CommitFormatter } from '../../git/formatters/commitFormatter'; import { StatusFileFormatter } from '../../git/formatters/statusFormatter'; @@ -11,6 +10,7 @@ import type { GitCommit } from '../../git/models/commit'; import type { GitFile } from '../../git/models/file'; import { getGitFileStatusIcon } from '../../git/models/file'; import type { GitRevisionReference } from '../../git/models/reference'; +import { configuration } from '../../system/configuration'; import { joinPaths } from '../../system/path'; import { getSettledValue } from '../../system/promise'; import type { FileHistoryView } from '../fileHistoryView'; diff --git a/src/views/nodes/folderNode.ts b/src/views/nodes/folderNode.ts index fc7899e..fe80f4c 100644 --- a/src/views/nodes/folderNode.ts +++ b/src/views/nodes/folderNode.ts @@ -1,6 +1,6 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; -import type { ViewsFilesConfig } from '../../configuration'; -import { ViewFilesLayout } from '../../configuration'; +import type { ViewsFilesConfig } from '../../config'; +import { ViewFilesLayout } from '../../config'; import { GitUri } from '../../git/gitUri'; import type { HierarchicalItem } from '../../system/array'; import { sortCompare } from '../../system/string'; diff --git a/src/views/nodes/lineHistoryNode.ts b/src/views/nodes/lineHistoryNode.ts index 97e4e6b..923330a 100644 --- a/src/views/nodes/lineHistoryNode.ts +++ b/src/views/nodes/lineHistoryNode.ts @@ -8,11 +8,11 @@ import type { GitLog } from '../../git/models/log'; import { isUncommitted } from '../../git/models/reference'; import type { RepositoryChangeEvent, RepositoryFileSystemChangeEvent } from '../../git/models/repository'; import { RepositoryChange, RepositoryChangeComparisonMode } from '../../git/models/repository'; -import { Logger } from '../../logger'; import { gate } from '../../system/decorators/gate'; import { debug } from '../../system/decorators/log'; import { memoize } from '../../system/decorators/memoize'; import { filterMap } from '../../system/iterable'; +import { Logger } from '../../system/logger'; import type { FileHistoryView } from '../fileHistoryView'; import type { LineHistoryView } from '../lineHistoryView'; import { LoadMoreNode, MessageNode } from './common'; diff --git a/src/views/nodes/lineHistoryTrackerNode.ts b/src/views/nodes/lineHistoryTrackerNode.ts index d04d79d..aace445 100644 --- a/src/views/nodes/lineHistoryTrackerNode.ts +++ b/src/views/nodes/lineHistoryTrackerNode.ts @@ -1,18 +1,18 @@ import type { Selection } from 'vscode'; import { TreeItem, TreeItemCollapsibleState, window } from 'vscode'; -import { UriComparer } from '../../comparers'; import { ContextKeys } from '../../constants'; import { setContext } from '../../context'; import type { GitCommitish } from '../../git/gitUri'; import { GitUri, unknownGitUri } from '../../git/gitUri'; import { deletedOrMissing } from '../../git/models/constants'; import { isBranchReference, isSha } from '../../git/models/reference'; -import { Logger } from '../../logger'; -import { getLogScope } from '../../logScope'; import { showReferencePicker } from '../../quickpicks/referencePicker'; +import { UriComparer } from '../../system/comparers'; import { gate } from '../../system/decorators/gate'; import { debug, log } from '../../system/decorators/log'; import { debounce } from '../../system/function'; +import { Logger } from '../../system/logger'; +import { getLogScope } from '../../system/logger.scope'; import type { LinesChangeEvent } from '../../trackers/gitLineTracker'; import type { FileHistoryView } from '../fileHistoryView'; import type { LineHistoryView } from '../lineHistoryView'; diff --git a/src/views/nodes/mergeConflictCurrentChangesNode.ts b/src/views/nodes/mergeConflictCurrentChangesNode.ts index 4d1422c..474f118 100644 --- a/src/views/nodes/mergeConflictCurrentChangesNode.ts +++ b/src/views/nodes/mergeConflictCurrentChangesNode.ts @@ -1,7 +1,6 @@ import type { Command } from 'vscode'; import { MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import type { DiffWithCommandArgs } from '../../commands'; -import { configuration } from '../../configuration'; import { Commands, CoreCommands, GlyphChars } from '../../constants'; import { CommitFormatter } from '../../git/formatters/commitFormatter'; import { GitUri } from '../../git/gitUri'; @@ -9,6 +8,7 @@ import type { GitFile } from '../../git/models/file'; import type { GitMergeStatus } from '../../git/models/merge'; import type { GitRebaseStatus } from '../../git/models/rebase'; import { getReferenceLabel } from '../../git/models/reference'; +import { configuration } from '../../system/configuration'; import type { FileHistoryView } from '../fileHistoryView'; import type { LineHistoryView } from '../lineHistoryView'; import type { ViewsWithCommits } from '../viewBase'; diff --git a/src/views/nodes/mergeConflictIncomingChangesNode.ts b/src/views/nodes/mergeConflictIncomingChangesNode.ts index 971134a..e226d7e 100644 --- a/src/views/nodes/mergeConflictIncomingChangesNode.ts +++ b/src/views/nodes/mergeConflictIncomingChangesNode.ts @@ -1,7 +1,6 @@ import type { Command } from 'vscode'; import { MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import type { DiffWithCommandArgs } from '../../commands'; -import { configuration } from '../../configuration'; import { Commands, CoreCommands, GlyphChars } from '../../constants'; import { CommitFormatter } from '../../git/formatters/commitFormatter'; import { GitUri } from '../../git/gitUri'; @@ -9,6 +8,7 @@ import type { GitFile } from '../../git/models/file'; import type { GitMergeStatus } from '../../git/models/merge'; import type { GitRebaseStatus } from '../../git/models/rebase'; import { getReferenceLabel } from '../../git/models/reference'; +import { configuration } from '../../system/configuration'; import type { FileHistoryView } from '../fileHistoryView'; import type { LineHistoryView } from '../lineHistoryView'; import type { ViewsWithCommits } from '../viewBase'; diff --git a/src/views/nodes/mergeStatusNode.ts b/src/views/nodes/mergeStatusNode.ts index 523cd38..1988937 100644 --- a/src/views/nodes/mergeStatusNode.ts +++ b/src/views/nodes/mergeStatusNode.ts @@ -1,5 +1,5 @@ import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; -import { ViewFilesLayout } from '../../configuration'; +import { ViewFilesLayout } from '../../config'; import { GitUri } from '../../git/gitUri'; import type { GitBranch } from '../../git/models/branch'; import type { GitMergeStatus } from '../../git/models/merge'; diff --git a/src/views/nodes/rebaseStatusNode.ts b/src/views/nodes/rebaseStatusNode.ts index 557f9d3..6c29faf 100644 --- a/src/views/nodes/rebaseStatusNode.ts +++ b/src/views/nodes/rebaseStatusNode.ts @@ -1,7 +1,7 @@ import type { Command } from 'vscode'; import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode'; import type { DiffWithPreviousCommandArgs } from '../../commands'; -import { configuration, ViewFilesLayout } from '../../configuration'; +import { ViewFilesLayout } from '../../config'; import { Commands, CoreCommands } from '../../constants'; import { CommitFormatter } from '../../git/formatters/commitFormatter'; import { GitUri } from '../../git/gitUri'; @@ -13,6 +13,7 @@ import { getReferenceLabel } from '../../git/models/reference'; import type { GitStatus } from '../../git/models/status'; import { makeHierarchical } from '../../system/array'; import { executeCoreCommand } from '../../system/command'; +import { configuration } from '../../system/configuration'; import { joinPaths, normalizePath } from '../../system/path'; import { getSettledValue } from '../../system/promise'; import { pluralize, sortCompare } from '../../system/string'; diff --git a/src/views/nodes/remoteNode.ts b/src/views/nodes/remoteNode.ts index 9b8a6b8..2c84dc5 100644 --- a/src/views/nodes/remoteNode.ts +++ b/src/views/nodes/remoteNode.ts @@ -1,5 +1,5 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode'; -import { ViewBranchesLayout } from '../../configuration'; +import { ViewBranchesLayout } from '../../config'; import { GlyphChars } from '../../constants'; import { GitUri } from '../../git/gitUri'; import type { GitRemote } from '../../git/models/remote'; diff --git a/src/views/nodes/repositoriesNode.ts b/src/views/nodes/repositoriesNode.ts index 580abf4..ed8524e 100644 --- a/src/views/nodes/repositoriesNode.ts +++ b/src/views/nodes/repositoriesNode.ts @@ -2,10 +2,10 @@ import type { TextEditor } from 'vscode'; import { Disposable, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import type { RepositoriesChangeEvent } from '../../git/gitProviderService'; import { GitUri, unknownGitUri } from '../../git/gitUri'; -import { Logger } from '../../logger'; import { gate } from '../../system/decorators/gate'; import { debug } from '../../system/decorators/log'; import { debounce, szudzikPairing } from '../../system/function'; +import { Logger } from '../../system/logger'; import type { RepositoriesView } from '../repositoriesView'; import { MessageNode } from './common'; import { RepositoryNode } from './repositoryNode'; diff --git a/src/views/nodes/resultsCommitsNode.ts b/src/views/nodes/resultsCommitsNode.ts index 82acddb..8dd586c 100644 --- a/src/views/nodes/resultsCommitsNode.ts +++ b/src/views/nodes/resultsCommitsNode.ts @@ -1,7 +1,7 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode'; -import { configuration } from '../../configuration'; import { GitUri } from '../../git/gitUri'; import type { GitLog } from '../../git/models/log'; +import { configuration } from '../../system/configuration'; import { gate } from '../../system/decorators/gate'; import { debug } from '../../system/decorators/log'; import { map } from '../../system/iterable'; diff --git a/src/views/nodes/resultsFilesNode.ts b/src/views/nodes/resultsFilesNode.ts index 1c5e955..3b23647 100644 --- a/src/views/nodes/resultsFilesNode.ts +++ b/src/views/nodes/resultsFilesNode.ts @@ -1,5 +1,5 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; -import { ViewFilesLayout } from '../../configuration'; +import { ViewFilesLayout } from '../../config'; import { GitUri } from '../../git/gitUri'; import type { GitDiffShortStat } from '../../git/models/diff'; import type { GitFile } from '../../git/models/file'; diff --git a/src/views/nodes/stashNode.ts b/src/views/nodes/stashNode.ts index c4abaa6..4e1aee9 100644 --- a/src/views/nodes/stashNode.ts +++ b/src/views/nodes/stashNode.ts @@ -1,10 +1,10 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode'; import { ViewFilesLayout } from '../../config'; -import { configuration } from '../../configuration'; import { CommitFormatter } from '../../git/formatters/commitFormatter'; import type { GitStashCommit } from '../../git/models/commit'; import type { GitStashReference } from '../../git/models/reference'; import { makeHierarchical } from '../../system/array'; +import { configuration } from '../../system/configuration'; import { joinPaths, normalizePath } from '../../system/path'; import { sortCompare } from '../../system/string'; import type { RepositoriesView } from '../repositoriesView'; diff --git a/src/views/nodes/statusFilesNode.ts b/src/views/nodes/statusFilesNode.ts index d86d680..3833dfc 100644 --- a/src/views/nodes/statusFilesNode.ts +++ b/src/views/nodes/statusFilesNode.ts @@ -1,5 +1,5 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode'; -import { ViewFilesLayout } from '../../configuration'; +import { ViewFilesLayout } from '../../config'; import { GitUri } from '../../git/gitUri'; import type { GitTrackingState } from '../../git/models/branch'; import type { GitCommit } from '../../git/models/commit'; diff --git a/src/views/nodes/tagNode.ts b/src/views/nodes/tagNode.ts index 1709cb5..cf764a3 100644 --- a/src/views/nodes/tagNode.ts +++ b/src/views/nodes/tagNode.ts @@ -1,5 +1,5 @@ import { TreeItem, TreeItemCollapsibleState, window } from 'vscode'; -import { ViewBranchesLayout } from '../../configuration'; +import { ViewBranchesLayout } from '../../config'; import { GlyphChars } from '../../constants'; import { emojify } from '../../emojis'; import type { GitUri } from '../../git/gitUri'; diff --git a/src/views/nodes/tagsNode.ts b/src/views/nodes/tagsNode.ts index 8c666c1..c640e41 100644 --- a/src/views/nodes/tagsNode.ts +++ b/src/views/nodes/tagsNode.ts @@ -1,5 +1,5 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; -import { ViewBranchesLayout } from '../../configuration'; +import { ViewBranchesLayout } from '../../config'; import { GitUri } from '../../git/gitUri'; import type { Repository } from '../../git/models/repository'; import { makeHierarchical } from '../../system/array'; diff --git a/src/views/nodes/viewNode.ts b/src/views/nodes/viewNode.ts index 826bcf1..b664750 100644 --- a/src/views/nodes/viewNode.ts +++ b/src/views/nodes/viewNode.ts @@ -10,11 +10,11 @@ import { getReferenceLabel } from '../../git/models/reference'; import { GitRemote } from '../../git/models/remote'; import type { RepositoryChangeEvent } from '../../git/models/repository'; import { Repository, RepositoryChange, RepositoryChangeComparisonMode } from '../../git/models/repository'; -import { getLoggableName } from '../../logger'; import type { SubscriptionChangeEvent } from '../../plus/subscription/subscriptionService'; import { gate } from '../../system/decorators/gate'; import { debug, log, logName } from '../../system/decorators/log'; import { is as isA, szudzikPairing } from '../../system/function'; +import { getLoggableName } from '../../system/logger'; import { pad } from '../../system/string'; import type { TreeViewNodeCollapsibleStateChangeEvent, View } from '../viewBase'; diff --git a/src/views/remotesView.ts b/src/views/remotesView.ts index 1443a77..21779e6 100644 --- a/src/views/remotesView.ts +++ b/src/views/remotesView.ts @@ -1,7 +1,7 @@ import type { CancellationToken, ConfigurationChangeEvent, Disposable } from 'vscode'; import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; -import type { RemotesViewConfig } from '../configuration'; -import { configuration, ViewBranchesLayout, ViewFilesLayout } from '../configuration'; +import type { RemotesViewConfig } from '../config'; +import { ViewBranchesLayout, ViewFilesLayout } from '../config'; import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; @@ -14,6 +14,7 @@ import type { GitRemote } from '../git/models/remote'; import type { RepositoryChangeEvent } from '../git/models/repository'; import { RepositoryChange, RepositoryChangeComparisonMode } from '../git/models/repository'; import { executeCommand } from '../system/command'; +import { configuration } from '../system/configuration'; import { gate } from '../system/decorators/gate'; import { BranchNode } from './nodes/branchNode'; import { BranchOrTagFolderNode } from './nodes/branchOrTagFolderNode'; diff --git a/src/views/repositoriesView.ts b/src/views/repositoriesView.ts index 2650a85..136f9a5 100644 --- a/src/views/repositoriesView.ts +++ b/src/views/repositoriesView.ts @@ -1,7 +1,7 @@ import type { CancellationToken, ConfigurationChangeEvent, Disposable, Event } from 'vscode'; import { EventEmitter, ProgressLocation, window } from 'vscode'; -import type { RepositoriesViewConfig } from '../configuration'; -import { configuration, ViewBranchesLayout, ViewFilesLayout, ViewShowBranchComparison } from '../configuration'; +import type { RepositoriesViewConfig } from '../config'; +import { ViewBranchesLayout, ViewFilesLayout, ViewShowBranchComparison } from '../config'; import { Commands, ContextKeys } from '../constants'; import type { Container } from '../container'; import { setContext } from '../context'; @@ -19,6 +19,7 @@ import { getReferenceLabel } from '../git/models/reference'; import type { GitRemote } from '../git/models/remote'; import type { GitWorktree } from '../git/models/worktree'; import { executeCommand } from '../system/command'; +import { configuration } from '../system/configuration'; import { gate } from '../system/decorators/gate'; import { BranchesNode } from './nodes/branchesNode'; import { BranchNode } from './nodes/branchNode'; diff --git a/src/views/searchAndCompareView.ts b/src/views/searchAndCompareView.ts index a076392..48ca7ff 100644 --- a/src/views/searchAndCompareView.ts +++ b/src/views/searchAndCompareView.ts @@ -1,7 +1,7 @@ import type { ConfigurationChangeEvent, Disposable } from 'vscode'; import { TreeItem, TreeItemCollapsibleState } from 'vscode'; -import type { SearchAndCompareViewConfig } from '../configuration'; -import { configuration, ViewFilesLayout } from '../configuration'; +import type { SearchAndCompareViewConfig } from '../config'; +import { ViewFilesLayout } from '../config'; import { Commands, ContextKeys } from '../constants'; import type { Container } from '../container'; import { setContext } from '../context'; @@ -15,6 +15,7 @@ import { getRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; import type { StoredNamedRef, StoredPinnedItem, StoredPinnedItems } from '../storage'; import { filterMap } from '../system/array'; import { executeCommand } from '../system/command'; +import { configuration } from '../system/configuration'; import { gate } from '../system/decorators/gate'; import { debug, log } from '../system/decorators/log'; import { updateRecordValue } from '../system/object'; diff --git a/src/views/stashesView.ts b/src/views/stashesView.ts index e9cf32e..f7d3b19 100644 --- a/src/views/stashesView.ts +++ b/src/views/stashesView.ts @@ -6,8 +6,8 @@ import type { TreeViewVisibilityChangeEvent, } from 'vscode'; import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; -import type { StashesViewConfig } from '../configuration'; -import { configuration, ViewFilesLayout } from '../configuration'; +import type { StashesViewConfig } from '../config'; +import { ViewFilesLayout } from '../config'; import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; @@ -16,6 +16,7 @@ import { getReferenceLabel } from '../git/models/reference'; import type { RepositoryChangeEvent } from '../git/models/repository'; import { RepositoryChange, RepositoryChangeComparisonMode } from '../git/models/repository'; import { executeCommand } from '../system/command'; +import { configuration } from '../system/configuration'; import { gate } from '../system/decorators/gate'; import { RepositoryNode } from './nodes/repositoryNode'; import { StashesNode } from './nodes/stashesNode'; diff --git a/src/views/tagsView.ts b/src/views/tagsView.ts index 12305a3..12f3005 100644 --- a/src/views/tagsView.ts +++ b/src/views/tagsView.ts @@ -1,7 +1,7 @@ import type { CancellationToken, ConfigurationChangeEvent, Disposable } from 'vscode'; import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; -import type { TagsViewConfig } from '../configuration'; -import { configuration, ViewBranchesLayout, ViewFilesLayout } from '../configuration'; +import type { TagsViewConfig } from '../config'; +import { ViewBranchesLayout, ViewFilesLayout } from '../config'; import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; @@ -10,6 +10,7 @@ import { getReferenceLabel } from '../git/models/reference'; import type { RepositoryChangeEvent } from '../git/models/repository'; import { RepositoryChange, RepositoryChangeComparisonMode } from '../git/models/repository'; import { executeCommand } from '../system/command'; +import { configuration } from '../system/configuration'; import { gate } from '../system/decorators/gate'; import { BranchOrTagFolderNode } from './nodes/branchOrTagFolderNode'; import { RepositoryNode } from './nodes/repositoryNode'; diff --git a/src/views/viewBase.ts b/src/views/viewBase.ts index a7c983e..6db5ac4 100644 --- a/src/views/viewBase.ts +++ b/src/views/viewBase.ts @@ -24,17 +24,18 @@ import type { ViewsCommonConfig, ViewsConfigKeys, WorktreesViewConfig, -} from '../configuration'; -import { configuration, viewsCommonConfigKeys, viewsConfigKeys } from '../configuration'; +} from '../config'; +import { viewsCommonConfigKeys, viewsConfigKeys } from '../config'; import type { Container } from '../container'; -import { Logger } from '../logger'; -import { getLogScope } from '../logScope'; import { executeCommand } from '../system/command'; +import { configuration } from '../system/configuration'; import { debug, log } from '../system/decorators/log'; import { once } from '../system/event'; import { debounce } from '../system/function'; +import { Logger } from '../system/logger'; +import { getLogScope } from '../system/logger.scope'; import { cancellable, isPromise } from '../system/promise'; -import type { TrackedUsageFeatures } from '../usageTracker'; +import type { TrackedUsageFeatures } from '../telemetry/usageTracker'; import type { BranchesView } from './branchesView'; import type { CommitsView } from './commitsView'; import type { ContributorsView } from './contributorsView'; diff --git a/src/views/viewCommands.ts b/src/views/viewCommands.ts index db5c295..a090474 100644 --- a/src/views/viewCommands.ts +++ b/src/views/viewCommands.ts @@ -7,7 +7,7 @@ import type { DiffWithWorkingCommandArgs, OpenFileAtRevisionCommandArgs, } from '../commands'; -import { configuration, FileAnnotationType, ViewShowBranchComparison } from '../configuration'; +import { FileAnnotationType, ViewShowBranchComparison } from '../config'; import { Commands, ContextKeys, CoreCommands, CoreGitCommands } from '../constants'; import type { Container } from '../container'; import { setContext } from '../context'; @@ -32,6 +32,7 @@ import { executeEditorCommand, registerCommand, } from '../system/command'; +import { configuration } from '../system/configuration'; import { debug } from '../system/decorators/log'; import { sequentialize } from '../system/function'; import { openWorkspace, OpenWorkspaceLocation } from '../system/utils'; diff --git a/src/views/worktreesView.ts b/src/views/worktreesView.ts index 0a0657e..1d8c01d 100644 --- a/src/views/worktreesView.ts +++ b/src/views/worktreesView.ts @@ -1,7 +1,7 @@ import type { CancellationToken, ConfigurationChangeEvent, Disposable, TreeViewVisibilityChangeEvent } from 'vscode'; import { ProgressLocation, ThemeColor, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; -import type { WorktreesViewConfig } from '../configuration'; -import { configuration, ViewFilesLayout, ViewShowBranchComparison } from '../configuration'; +import type { WorktreesViewConfig } from '../config'; +import { ViewFilesLayout, ViewShowBranchComparison } from '../config'; import { Commands } from '../constants'; import type { Container } from '../container'; import { PlusFeatures } from '../features'; @@ -12,6 +12,7 @@ import type { GitWorktree } from '../git/models/worktree'; import { ensurePlusFeaturesEnabled } from '../plus/subscription/utils'; import { getSubscriptionTimeRemaining, SubscriptionState } from '../subscription'; import { executeCommand } from '../system/command'; +import { configuration } from '../system/configuration'; import { gate } from '../system/decorators/gate'; import { pluralize } from '../system/string'; import { RepositoryNode } from './nodes/repositoryNode'; diff --git a/src/vsls/guest.ts b/src/vsls/guest.ts index d42cf92..c07e4ef 100644 --- a/src/vsls/guest.ts +++ b/src/vsls/guest.ts @@ -3,9 +3,9 @@ import { window } from 'vscode'; import type { LiveShare, SharedServiceProxy } from '../@types/vsls'; import type { Container } from '../container'; import type { GitCommandOptions } from '../git/commandOptions'; -import { Logger } from '../logger'; -import { getLogScope } from '../logScope'; import { debug, log } from '../system/decorators/log'; +import { Logger } from '../system/logger'; +import { getLogScope } from '../system/logger.scope'; import { VslsHostService } from './host'; import type { RepositoryProxy, RequestType } from './protocol'; import { GetRepositoriesForUriRequestType, GitCommandRequestType } from './protocol'; diff --git a/src/vsls/host.ts b/src/vsls/host.ts index 748e248..cb9b316 100644 --- a/src/vsls/host.ts +++ b/src/vsls/host.ts @@ -3,10 +3,10 @@ import { Disposable, Uri, workspace } from 'vscode'; import { git } from '@env/providers'; import type { LiveShare, SharedService } from '../@types/vsls'; import type { Container } from '../container'; -import { Logger } from '../logger'; -import { getLogScope } from '../logScope'; import { debug, log } from '../system/decorators/log'; import { join } from '../system/iterable'; +import { Logger } from '../system/logger'; +import { getLogScope } from '../system/logger.scope'; import { isVslsRoot, normalizePath } from '../system/path'; import type { GetRepositoriesForUriRequest, diff --git a/src/vsls/vsls.ts b/src/vsls/vsls.ts index 3f58974..6818db1 100644 --- a/src/vsls/vsls.ts +++ b/src/vsls/vsls.ts @@ -1,13 +1,13 @@ import { Disposable, extensions, workspace } from 'vscode'; import type { LiveShare, LiveShareExtension, SessionChangeEvent } from '../@types/vsls'; -import { configuration } from '../configuration'; import { ContextKeys, Schemes } from '../constants'; import type { Container } from '../container'; import { setContext } from '../context'; -import { Logger } from '../logger'; +import { configuration } from '../system/configuration'; import { debug } from '../system/decorators/log'; import { timeout } from '../system/decorators/timeout'; import { once } from '../system/event'; +import { Logger } from '../system/logger'; import type { Deferred } from '../system/promise'; import { defer } from '../system/promise'; import { VslsGuestService } from './guest'; diff --git a/src/webviews/apps/shared/appBase.ts b/src/webviews/apps/shared/appBase.ts index 6d32e81..2c8bfa7 100644 --- a/src/webviews/apps/shared/appBase.ts +++ b/src/webviews/apps/shared/appBase.ts @@ -1,7 +1,7 @@ /*global window document*/ -import { LogLevel } from '../../../constants'; -import { Logger } from '../../../logger'; import { debounce } from '../../../system/function'; +import { Logger } from '../../../system/logger'; +import { LogLevel } from '../../../system/logger.constants'; import type { IpcCommandType, IpcMessage, diff --git a/src/webviews/commitDetails/commitDetailsWebviewView.ts b/src/webviews/commitDetails/commitDetailsWebviewView.ts index 77138ff..ea06f6d 100644 --- a/src/webviews/commitDetails/commitDetailsWebviewView.ts +++ b/src/webviews/commitDetails/commitDetailsWebviewView.ts @@ -2,7 +2,6 @@ import type { CancellationToken, ConfigurationChangeEvent, TextDocumentShowOptio import { CancellationTokenSource, Disposable, Uri, ViewColumn, window } from 'vscode'; import { serializeAutolink } from '../../annotations/autolinks'; import type { CopyShaToClipboardCommandArgs } from '../../commands'; -import { configuration } from '../../configuration'; import { Commands, ContextKeys, CoreCommands } from '../../constants'; import type { Container } from '../../container'; import { getContext } from '../../context'; @@ -27,15 +26,16 @@ import { serializePullRequest } from '../../git/models/pullRequest'; import type { GitRevisionReference } from '../../git/models/reference'; import { getReferenceFromRevision } from '../../git/models/reference'; import type { GitRemote } from '../../git/models/remote'; -import { Logger } from '../../logger'; -import { getLogScope } from '../../logScope'; import type { ShowInCommitGraphCommandArgs } from '../../plus/webviews/graph/graphWebview'; import { executeCommand, executeCoreCommand } from '../../system/command'; +import { configuration } from '../../system/configuration'; import type { DateTimeFormat } from '../../system/date'; import { debug, log } from '../../system/decorators/log'; import type { Deferrable } from '../../system/function'; import { debounce } from '../../system/function'; import { map, union } from '../../system/iterable'; +import { Logger } from '../../system/logger'; +import { getLogScope } from '../../system/logger.scope'; import type { PromiseCancelledError } from '../../system/promise'; import { getSettledValue } from '../../system/promise'; import type { Serialized } from '../../system/serialize'; diff --git a/src/webviews/home/homeWebviewView.ts b/src/webviews/home/homeWebviewView.ts index f9d499d..b51cbc1 100644 --- a/src/webviews/home/homeWebviewView.ts +++ b/src/webviews/home/homeWebviewView.ts @@ -2,7 +2,6 @@ import type { ConfigurationChangeEvent, Disposable } from 'vscode'; import { window } from 'vscode'; import { getAvatarUriFromGravatarEmail } from '../../avatars'; import { ViewsLayout } from '../../commands/setViewsLayout'; -import { configuration } from '../../configuration'; import { ContextKeys, CoreCommands } from '../../constants'; import type { Container } from '../../container'; import { getContext, onDidChangeContext } from '../../context'; @@ -12,6 +11,7 @@ import { ensurePlusFeaturesEnabled } from '../../plus/subscription/utils'; import type { StorageChangeEvent } from '../../storage'; import type { Subscription } from '../../subscription'; import { executeCoreCommand, registerCommand } from '../../system/command'; +import { configuration } from '../../system/configuration'; import type { Deferrable } from '../../system/function'; import { debounce } from '../../system/function'; import type { IpcMessage } from '../protocol'; diff --git a/src/webviews/protocol.ts b/src/webviews/protocol.ts index 91d2e30..19378fa 100644 --- a/src/webviews/protocol.ts +++ b/src/webviews/protocol.ts @@ -1,5 +1,5 @@ import type { Config } from '../config'; -import type { ConfigPath, ConfigPathValue } from '../configuration'; +import type { ConfigPath, ConfigPathValue } from '../system/configuration'; import type { CustomConfigPath, CustomConfigPathValue } from './webviewWithConfigBase'; export interface IpcMessage { diff --git a/src/webviews/rebase/rebaseEditor.ts b/src/webviews/rebase/rebaseEditor.ts index 5ac6ed2..fde5aa4 100644 --- a/src/webviews/rebase/rebaseEditor.ts +++ b/src/webviews/rebase/rebaseEditor.ts @@ -8,7 +8,6 @@ import type { import { ConfigurationTarget, Disposable, Position, Range, Uri, window, workspace, WorkspaceEdit } from 'vscode'; import { getNonce } from '@env/crypto'; import { ShowCommitsInViewCommand } from '../../commands'; -import { configuration } from '../../configuration'; import { ContextKeys, CoreCommands } from '../../constants'; import type { Container } from '../../container'; import { setContext } from '../../context'; @@ -16,13 +15,14 @@ import { emojify } from '../../emojis'; import type { GitCommit } from '../../git/models/commit'; import { createReference } from '../../git/models/reference'; import { RepositoryChange, RepositoryChangeComparisonMode } from '../../git/models/repository'; -import { Logger } from '../../logger'; import { showRebaseSwitchToTextWarningMessage } from '../../messages'; import { executeCoreCommand } from '../../system/command'; +import { configuration } from '../../system/configuration'; import { debug, log } from '../../system/decorators/log'; import type { Deferrable } from '../../system/function'; import { debounce } from '../../system/function'; import { join, map } from '../../system/iterable'; +import { Logger } from '../../system/logger'; import { normalizePath } from '../../system/path'; import type { IpcMessage, WebviewFocusChangedParams } from '../protocol'; import { onIpc, WebviewFocusChangedCommandType } from '../protocol'; diff --git a/src/webviews/settings/settingsWebview.ts b/src/webviews/settings/settingsWebview.ts index 5936a3e..bfc79fc 100644 --- a/src/webviews/settings/settingsWebview.ts +++ b/src/webviews/settings/settingsWebview.ts @@ -1,8 +1,8 @@ import { workspace } from 'vscode'; -import { configuration } from '../../configuration'; import { Commands, ContextKeys } from '../../constants'; import type { Container } from '../../container'; import { registerCommand } from '../../system/command'; +import { configuration } from '../../system/configuration'; import { DidOpenAnchorNotificationType } from '../protocol'; import { WebviewWithConfigBase } from '../webviewWithConfigBase'; import type { State } from './protocol'; diff --git a/src/webviews/webviewBase.ts b/src/webviews/webviewBase.ts index e793527..0cdab70 100644 --- a/src/webviews/webviewBase.ts +++ b/src/webviews/webviewBase.ts @@ -14,7 +14,7 @@ import { setContext } from '../context'; import { executeCommand, registerCommand } from '../system/command'; import { debug, log, logName } from '../system/decorators/log'; import { serialize } from '../system/decorators/serialize'; -import type { TrackedUsageFeatures } from '../usageTracker'; +import type { TrackedUsageFeatures } from '../telemetry/usageTracker'; import type { IpcMessage, IpcMessageParams, IpcNotificationType, WebviewFocusChangedParams } from './protocol'; import { ExecuteCommandType, onIpc, WebviewFocusChangedCommandType, WebviewReadyCommandType } from './protocol'; diff --git a/src/webviews/webviewViewBase.ts b/src/webviews/webviewViewBase.ts index 88fcc9c..16cf0bd 100644 --- a/src/webviews/webviewViewBase.ts +++ b/src/webviews/webviewViewBase.ts @@ -11,12 +11,12 @@ import { getNonce } from '@env/crypto'; import type { Commands, ContextKeys } from '../constants'; import type { Container } from '../container'; import { setContext } from '../context'; -import { Logger } from '../logger'; -import { getLogScope } from '../logScope'; import { executeCommand } from '../system/command'; import { debug, log, logName } from '../system/decorators/log'; import { serialize } from '../system/decorators/serialize'; -import type { TrackedUsageFeatures } from '../usageTracker'; +import { Logger } from '../system/logger'; +import { getLogScope } from '../system/logger.scope'; +import type { TrackedUsageFeatures } from '../telemetry/usageTracker'; import type { IpcMessage, IpcMessageParams, IpcNotificationType, WebviewFocusChangedParams } from './protocol'; import { ExecuteCommandType, onIpc, WebviewFocusChangedCommandType, WebviewReadyCommandType } from './protocol'; diff --git a/src/webviews/webviewWithConfigBase.ts b/src/webviews/webviewWithConfigBase.ts index bc83ec3..327fe81 100644 --- a/src/webviews/webviewWithConfigBase.ts +++ b/src/webviews/webviewWithConfigBase.ts @@ -1,15 +1,15 @@ import type { ConfigurationChangeEvent, WebviewPanelOnDidChangeViewStateEvent } from 'vscode'; import { ConfigurationTarget } from 'vscode'; -import type { Path, PathValue } from '../configuration'; -import { configuration } from '../configuration'; import type { Commands, ContextKeys } from '../constants'; import type { Container } from '../container'; import { CommitFormatter } from '../git/formatters/commitFormatter'; import { GitCommit, GitCommitIdentity } from '../git/models/commit'; import { GitFileChange, GitFileIndexStatus } from '../git/models/file'; import { PullRequest, PullRequestState } from '../git/models/pullRequest'; -import { Logger } from '../logger'; -import type { TrackedUsageFeatures } from '../usageTracker'; +import type { Path, PathValue } from '../system/configuration'; +import { configuration } from '../system/configuration'; +import { Logger } from '../system/logger'; +import type { TrackedUsageFeatures } from '../telemetry/usageTracker'; import type { IpcMessage } from './protocol'; import { DidChangeConfigurationNotificationType, diff --git a/src/webviews/welcome/welcomeWebview.ts b/src/webviews/welcome/welcomeWebview.ts index 5b268f1..30a0f67 100644 --- a/src/webviews/welcome/welcomeWebview.ts +++ b/src/webviews/welcome/welcomeWebview.ts @@ -1,6 +1,6 @@ -import { configuration } from '../../configuration'; import { Commands, ContextKeys } from '../../constants'; import type { Container } from '../../container'; +import { configuration } from '../../system/configuration'; import { WebviewWithConfigBase } from '../webviewWithConfigBase'; import type { State } from './protocol';