-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: reorganise code structure to prepare for Snyk OSS integration
- Loading branch information
1 parent
27ba2d2
commit 7582fc1
Showing
65 changed files
with
693 additions
and
664 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as vscode from 'vscode'; | ||
import { configuration } from '../../common/configuration'; | ||
import { ContextService, IContextService } from '../../common/services/contextService'; | ||
import { IOpenerService, OpenerService } from '../../common/services/openerService'; | ||
import { IViewManagerService, ViewManagerService } from '../../common/services/viewManagerService'; | ||
import SnykEditorsWatcher from '../../snykCode/watchers/editorsWatcher'; | ||
import { ISnykCode, SnykCode } from '../../snykCode/code'; | ||
import SnykStatusBarItem, { IStatusBarItem } from '../statusBarItem/statusBarItem'; | ||
import SettingsWatcher from '../../common/watchers/settingsWatcher'; | ||
import { IWatcher } from '../../common/watchers/interfaces'; | ||
import { IBaseSnykModule, errorType } from './interfaces'; | ||
|
||
export default abstract class BaseSnykModule implements IBaseSnykModule { | ||
statusBarItem: IStatusBarItem; | ||
filesWatcher: vscode.FileSystemWatcher; | ||
editorsWatcher: IWatcher; | ||
settingsWatcher: IWatcher; | ||
contextService: IContextService; | ||
openerService: IOpenerService; | ||
viewManagerService: IViewManagerService; | ||
|
||
snykCode: ISnykCode; | ||
|
||
constructor() { | ||
this.statusBarItem = new SnykStatusBarItem(); | ||
this.editorsWatcher = new SnykEditorsWatcher(); | ||
this.settingsWatcher = new SettingsWatcher(); | ||
this.viewManagerService = new ViewManagerService(); | ||
this.contextService = new ContextService(); | ||
this.openerService = new OpenerService(); | ||
this.snykCode = new SnykCode( | ||
configuration, | ||
this.openerService, | ||
this.viewManagerService, | ||
this.filesWatcher, | ||
this.processError.bind(this), | ||
); | ||
} | ||
|
||
abstract processError(error: errorType, options?: { [key: string]: any }): Promise<void>; | ||
|
||
abstract startExtension(): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { IContextService } from '../../common/services/contextService'; | ||
import { IOpenerService } from '../../common/services/openerService'; | ||
import { IViewManagerService } from '../../common/services/viewManagerService'; | ||
import { ISnykCode } from '../../snykCode/code'; | ||
import { IStatusBarItem } from '../statusBarItem/statusBarItem'; | ||
import { ExtensionContext, FileSystemWatcher } from 'vscode'; | ||
import { IWatcher } from '../../common/watchers/interfaces'; | ||
|
||
export interface IBaseSnykModule { | ||
statusBarItem: IStatusBarItem; | ||
filesWatcher: FileSystemWatcher; | ||
settingsWatcher: IWatcher; | ||
contextService: IContextService; | ||
openerService: IOpenerService; | ||
viewManagerService: IViewManagerService; | ||
snykCode: ISnykCode; | ||
|
||
// Abstract methods | ||
processError(error: errorType, options?: { [key: string]: any }): Promise<void>; | ||
startExtension(): Promise<void>; | ||
} | ||
|
||
export interface IReportModule { | ||
resetTransientErrors(): void; | ||
} | ||
|
||
export interface ILoginModule { | ||
initiateLogin(): Promise<void>; | ||
checkSession(): Promise<string>; | ||
checkCodeEnabled(): Promise<boolean>; | ||
checkAdvancedMode(): Promise<void>; | ||
} | ||
|
||
export interface ISnykLib { | ||
setMode(mode: string): void; | ||
enableCode(): Promise<void>; | ||
} | ||
|
||
export interface IExtension extends IBaseSnykModule, IReportModule, ILoginModule, ISnykLib { | ||
context: ExtensionContext | undefined; | ||
activate(context: ExtensionContext): void; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export type errorType = Error | any; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20
src/snyk/lib/modules/ReportModule.ts → src/snyk/base/modules/reportModule.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 8 additions & 4 deletions
12
...yk/lib/statusBarItem/SnykStatusBarItem.ts → src/snyk/base/statusBarItem/statusBarItem.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/snyk/view/emptyTreeDataProvider.ts → src/snyk/base/views/emptyTreeDataProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.