11import * as vscode from "vscode" ;
2- // import * as path from "path";
3- // import * as nodeFs from "fs";
42
53import DeepCode from "../../../interfaces/DeepCodeInterfaces" ;
6- import http from "../../http/requests" ;
74import BundlesModule from "./BundlesModule" ;
85
9- // import { INSTALL_STATUS, STATUSFILE_NAME, DEEPCODE_NAME } from "../../constants/general";
10-
116export default class DeepCodeLib extends BundlesModule implements DeepCode . DeepCodeLibInterface {
127
138 public activateWatchers ( ) : void {
@@ -17,31 +12,27 @@ export default class DeepCodeLib extends BundlesModule implements DeepCode.DeepC
1712 this . settingsWatcher . activate ( this ) ;
1813 }
1914
20- // public async preActivateActions(): Promise<void> {
21- // // let status = INSTALL_STATUS.installed;
22- // // if (process.env.NODE_ENV === "production") {
23- // // status = this.manageExtensionStatus();
24- // // }
25- // await this.activateActions();
26- // }
27-
28- // public manageExtensionStatus(): string {
29- // const extension = vscode.extensions.all.find(
30- // el => el.packageJSON.displayName === DEEPCODE_NAME
31- // );
32- // if (extension) {
33- // const statusFilePath = path.join(extension.extensionPath, `/${STATUSFILE_NAME}`);
34- // const extensionStatus = nodeFs.readFileSync(statusFilePath, "utf8");
35- // if (extensionStatus === INSTALL_STATUS.justInstalled) {
36- // this.store.cleanStore();
37- // nodeFs.writeFileSync(statusFilePath, INSTALL_STATUS.installed);
38- // return INSTALL_STATUS.justInstalled;
39- // }
40- // }
41- // return INSTALL_STATUS.installed;
42- // }
4315
4416 public async activateExtensionAnalyzeActions ( ) : Promise < void > {
17+
18+ // First, check logged in or not
19+ let loggedIn = await this . checkSession ( ) ;
20+ if ( ! loggedIn ) {
21+ await this . initiateLogin ( ) ;
22+ loggedIn = await this . checkSession ( ) ;
23+ if ( ! loggedIn ) {
24+ return ;
25+ }
26+ }
27+
28+ // Second, check user consent on sending files to server
29+ if ( ! this . uploadApproved ) {
30+ await this . askUploadApproval ( ) ;
31+ if ( ! this . uploadApproved ) {
32+ return ;
33+ }
34+ }
35+
4536 const workspaceFolders : readonly vscode . WorkspaceFolder [ ] | undefined = vscode . workspace . workspaceFolders ;
4637
4738 if ( ! workspaceFolders || ! workspaceFolders . length ) {
@@ -55,24 +46,6 @@ export default class DeepCodeLib extends BundlesModule implements DeepCode.DeepC
5546
5647 await this . updateHashesBundles ( ) ;
5748
58- // First, check logged in or not
59- let loggedIn = await this . checkSession ( ) ;
60- if ( ! loggedIn ) {
61- await this . initiateLogin ( ) ;
62- loggedIn = await this . checkSession ( ) ;
63- if ( ! loggedIn ) {
64- return ;
65- }
66- }
67-
68- // Second, check user consent on sending files to server
69- if ( ! this . uploadApproved ) {
70- await this . askUploadApproval ( ) ;
71- if ( ! this . uploadApproved ) {
72- return ;
73- }
74- }
75-
7649 // Third, initiate analysis
7750 try {
7851 // Main entry point to
0 commit comments