Skip to content

Commit 92c3bb7

Browse files
committed
feat: deprecate extension
1 parent 21066d4 commit 92c3bb7

File tree

7 files changed

+55
-3
lines changed

7 files changed

+55
-3
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Latest update 🗞️ (start here first 👇)
2+
3+
- Dear developers 👋, thank you for your support and feedback!
4+
- With the DeepCode acquisition by [Snyk](https://snyk.io) we will be starting a new journey, a better one, towards helping you write robust and secure application code. The DeepCode extension will be replaced by [Snyk's VS Code extension](https://marketplace.visualstudio.com/items?itemName=snyk-security.snyk-vulnerability-scanner) which includes DeepCode's functionality and more.
5+
- If you want to read more about it, here is the [official announcement](https://www.deepcode.ai/). We will start sunsetting the official DeepCode API in August, 2021. In the mean time we will do one last update of the VS Code extension with this message to ensure you are up to date.
6+
- We invite you to join us and start using the new Snyk extension! We are excited and looking forward to helping you build stable and secure applications 🚀
7+
18
# DeepCode for Visual Studio Code
29

310
**The Visual Studio Code extension provided by <a href="https://www.deepcode.ai/">DeepCode.ai</a> finds bugs and critical vulnerabilities in your code. We support JavaScript and TypeScript, Java, Python, C/C++, C# and PHP.**

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@
130130
"contents": "DeepCode is temporarily unavailable\nWe are automatically retrying to connect...",
131131
"when": "deepcode:error == 'transient'"
132132
},
133+
{
134+
"view": "deepcode.views.analysis",
135+
"contents": "The DeepCode extension is deprecated. Please use [Snyk Vulnerability Scanner](command:workbench.extensions.search?%22snyk-security.snyk-vulnerability-scanner%22) with included DeepCode's functionality and more.",
136+
"when": "deepcode:deprecated"
137+
},
133138
{
134139
"view": "deepcode.views.analysis",
135140
"contents": "DeepCode has encountered a problem. Please restart the extension: \n[Restart](command:deepcode.start 'Restart DeepCode')\nIf the error persists, please check your [settings](command:deepcode.settings) and [contact us](https://www.deepcode.ai/feedback?select=2?utm_source=vsc)!",
@@ -138,7 +143,7 @@
138143
{
139144
"view": "deepcode.views.analysis",
140145
"contents": "Welcome to DeepCode for Visual Studio Code. 👋\nLet's start by connecting VS Code with DeepCode:\n[Connect VS Code with DeepCode](command:deepcode.login 'Connect with DeepCode')\n👉 DeepCode's mission is to finds bugs, fast. Connect with DeepCode to start your first analysis!",
141-
"when": "!deepcode:error && !deepcode:loggedIn"
146+
"when": "!deepcode:error && !deepcode:loggedIn && !deepcode:deprecated"
142147
},
143148
{
144149
"view": "deepcode.views.analysis",
@@ -187,7 +192,7 @@
187192
"commandPalette": [
188193
{
189194
"command": "deepcode.login",
190-
"when": "!deepcode:loggedIn"
195+
"when": "!deepcode:loggedIn && !deepcode:deprecated"
191196
},
192197
{
193198
"command": "deepcode.dcignore",
@@ -199,7 +204,8 @@
199204
{
200205
"command": "deepcode.start",
201206
"title": "DeepCode re-scan",
202-
"icon": "$(refresh)"
207+
"icon": "$(refresh)",
208+
"enablement": "!deepcode:deprecated"
203209
},
204210
{
205211
"command": "deepcode.settings",

src/deepcode/DeepCodeExtension.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
DEEPCODE_VIEW_SUPPORT,
2323
DEEPCODE_VIEW_ANALYSIS,
2424
DEEPCODE_ANALYSIS_STATUS,
25+
DEEPCODE_CONTEXT,
2526
} from './constants/views';
2627
import { openDeepcodeSettingsCommand, createDCIgnoreCommand } from './utils/vscodeCommandsUtils';
2728
import { errorsLogs } from './messages/errorsServerLogMessages';
@@ -161,6 +162,10 @@ class DeepCodeExtension extends DeepCodeLib implements ExtensionInterface {
161162
}),
162163
);
163164

165+
if (this.isApiDeprecated(context)) {
166+
return;
167+
}
168+
164169
// Actually start analysis
165170
this.startExtension();
166171
}
@@ -169,6 +174,23 @@ class DeepCodeExtension extends DeepCodeLib implements ExtensionInterface {
169174
emitter.removeAllListeners();
170175
}
171176

177+
private isApiDeprecated(context: vscode.ExtensionContext): boolean {
178+
// API is deprecated from 01.09.2021 onwards
179+
const deprecated = Date.now() >= new Date(2021, 8, 1).getTime();
180+
if (deprecated) {
181+
this.setContext(DEEPCODE_CONTEXT.DEPRECATED, true);
182+
return true;
183+
}
184+
185+
this.checkDeprecationNote(context).catch(err =>
186+
this.processError(err, {
187+
message: errorsLogs.checkDeprecationNoteMode,
188+
}),
189+
);
190+
191+
return false;
192+
}
193+
172194
onSupportedFilesLoaded(data: ISupportedFiles | null) {
173195
const msg = data ? 'Ignore rules loading' : 'Loading';
174196

src/deepcode/constants/views.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const DEEPCODE_CONTEXT = {
1212
ERROR: 'error',
1313
MODE: 'mode',
1414
ADVANCED: 'advanced',
15+
DEPRECATED: 'deprecated',
1516
};
1617

1718
export const DEEPCODE_ERROR_CODES = {

src/deepcode/lib/modules/LoginModule.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const sleep = (duration: number) => new Promise(resolve => setTimeout(resolve, d
1515
abstract class LoginModule extends ReportModule implements LoginModuleInterface {
1616
private pendingLogin: boolean = false;
1717
private pendingToken = '';
18+
private readonly deprecationNoteKey = 'deepcode.deprecationNoteMonth';
1819

1920
async initiateLogin(): Promise<void> {
2021
await this.setContext(DEEPCODE_CONTEXT.LOGGEDIN, false);
@@ -131,6 +132,16 @@ abstract class LoginModule extends ReportModule implements LoginModuleInterface
131132
async checkAdvancedMode(): Promise<void> {
132133
await this.setContext(DEEPCODE_CONTEXT.ADVANCED, this.shouldShowAdvancedView);
133134
}
135+
136+
async checkDeprecationNote(context: vscode.ExtensionContext): Promise<void> {
137+
const currentMonth = new Date().getMonth();
138+
const lastMessageMonth: number | undefined = context.globalState.get(this.deprecationNoteKey);
139+
140+
if (!lastMessageMonth || currentMonth != lastMessageMonth) {
141+
context.globalState.update(this.deprecationNoteKey, currentMonth);
142+
await vscode.window.showInformationMessage(deepCodeMessages.deprecation.msg);
143+
}
144+
}
134145
}
135146

136147
export default LoginModule;

src/deepcode/messages/deepCodeMessages.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ export const deepCodeMessages = {
33
msg: "Welcome to DeepCode! Check out our dashboard to start analyzing your code",
44
button: "Check it out",
55
},
6+
deprecation: {
7+
msg:
8+
'The DeepCode extension is deprecated. Please use [Snyk Vulnerability Scanner](command:workbench.extensions.search?%22snyk-security.snyk-vulnerability-scanner%22) with included DeepCode\'s functionality and more.',
9+
},
610
};

src/deepcode/messages/errorsServerLogMessages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const errorsLogs = {
2727
loadingBadge: 'Failed to set loading badge icon',
2828
welcomeNotification: 'Failed to handle welcome notification',
2929
checkAdvancedMode: 'Failed to check advanced mode',
30+
checkDeprecationNoteMode: 'Failed to check deprecation note',
3031
suggestionView: 'Failed to show suggestion view',
3132
suggestionViewMessage: 'Failed handle message from suggestion view',
3233
};

0 commit comments

Comments
 (0)