Skip to content

Commit

Permalink
Fix spectral installtion motification bug
Browse files Browse the repository at this point in the history
  • Loading branch information
guylev008 committed Aug 30, 2023
1 parent 748cd7a commit 40d6838
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 27 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# SpectralOps - Automated Code Security Change Log
## [1.1.2]

- Fix Spectral installtion notification bug
## [1.1.1]

- Install Spectral from the extension
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "spectral-vscode-extension",
"displayName": "SpectralOps - A Check Point Solution",
"description": "Monitor your code for exposed API keys, tokens, credentials, and high-risk security misconfigurations",
"version": "1.1.1",
"version": "1.1.2",
"publisher": "SpectralOps",
"icon": "media/spectral.png",
"homepage": "https://spectralops.io/",
Expand Down
45 changes: 21 additions & 24 deletions src/spectral/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,35 +109,32 @@ export const setupSpectral = async (
tooltip: 'Installing Spectral',
})
const contextService = ContextService.getInstance()
if (contextService.getContext(ENABLE_INSTALL_AGENT)) {
try {
contextService.setContext(ENABLE_INSTALL_AGENT, false)
inProgressStatusBarItem.show()
await spectralAgentService.installSpectral()
inProgressStatusBarItem.dispose()
contextService.setContext(HAS_SPECTRAL_INSTALLED, true)
const extensionContext = PersistenceContext.getInstance()
extensionContext.updateGlobalStateValue(
AGENT_LAST_UPDATE_DATE,
Date.now()
)
} catch (error) {
inProgressStatusBarItem.dispose()
const logger = LoggerService.getInstance()
logger.error(error)
ShowNotificationMessage({
messageType: 'error',
messageText: `Spectral installation failed`,
items: ['See output'],
}).then(() => logger.showOutput())
}
contextService.setContext(ENABLE_INSTALL_AGENT, true)
} else {
try {
contextService.setContext(ENABLE_INSTALL_AGENT, false)
inProgressStatusBarItem.show()
ShowNotificationMessage({
messageType: 'info',
messageText: `Spectral installation is in progress`,
})
await spectralAgentService.installSpectral()
inProgressStatusBarItem.dispose()
contextService.setContext(HAS_SPECTRAL_INSTALLED, true)
const extensionContext = PersistenceContext.getInstance()
extensionContext.updateGlobalStateValue(AGENT_LAST_UPDATE_DATE, Date.now())
} catch (error) {
inProgressStatusBarItem.dispose()
const logger = LoggerService.getInstance()
logger.error(error)
ShowNotificationMessage({
messageType: 'error',
messageText: `Spectral installation failed`,
items: ['See output'],
}).then(() => logger.showOutput())
}
ShowNotificationMessage({
messageType: 'info',
messageText: `Spectral installation completed`,
})
}

const scanWorkspaces = async ({
Expand Down
5 changes: 3 additions & 2 deletions src/spectral/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ export class SpectralExtension {
this.initializeExtension(vsCodeContext)
const isSpectralInstalled =
await this.spectralAgentService.checkForSpectralBinary()

this.setSpectralInstallationContext(isSpectralInstalled)
if (isSpectralInstalled && shouldUpdateSpectralAgent()) {
await setupSpectral(this.spectralAgentService)
}
this.setSpectralInstallationContext(isSpectralInstalled)
AnalyticsService.init()
} catch (error) {
this.logger.error(error)
Expand All @@ -89,9 +90,9 @@ export class SpectralExtension {
public async setSpectralInstallationContext(
isSpectralInstalled: Boolean
): Promise<void> {
this.contextService.setContext(ENABLE_INSTALL_AGENT, true)
if (!isSpectralInstalled) {
this.contextService.setContext(HAS_SPECTRAL_INSTALLED, false)
this.contextService.setContext(ENABLE_INSTALL_AGENT, true)
return
}
this.contextService.setContext(HAS_SPECTRAL_INSTALLED, true)
Expand Down

0 comments on commit 40d6838

Please sign in to comment.