Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #77 from zzzz465/feature/insider-detection
Browse files Browse the repository at this point in the history
feature: add insider detection
  • Loading branch information
zzzz465 authored Feb 16, 2022
2 parents e3c3184 + 8143d55 commit e907eff
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vsc-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ModManager } from './mod/modManager'
import { ExtensionVersionToken } from './version'
import { ExtensionContextToken } from './extension'
import { UpdateNotification } from './notification/updateNotification'
import checkInsider from './insiderCheck'

const disposables: vscode.Disposable[] = []

Expand All @@ -26,6 +27,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>

container.register(ExtensionContextToken, { useValue: context })

// check insider version exists (main / insider cannot co-exists)
await checkInsider()

// check version is updated.
const updateNotification = container.resolve(UpdateNotification)
updateNotification.checkFirstRunThisVersion()
Expand Down
45 changes: 45 additions & 0 deletions vsc-extension/src/insiderCheck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { container } from 'tsyringe'
import { ExtensionContext } from 'vscode'
import { ExtensionContextToken } from './extension'
import * as vscode from 'vscode'

export default async function checkInsider() {
const insiderId = 'madeline.rwxml-language-server-insider'
const search = 'rwxml'

const insiderExtension = vscode.extensions.getExtension(insiderId)
if (insiderExtension === undefined) {
return
}

const res = await vscode.window.showInformationMessage(
'RWXML: insider version is now deprecated. Please remove the insider version.',
'Remove Insider Version',
'No Thanks'
)

if (res === 'Remove Insider Version') {
await vscode.commands.executeCommand('workbench.extensions.search', search)
await vscode.commands.executeCommand('workbench.extensions.uninstallExtension', insiderId)

const res2 = await vscode.window.showInformationMessage(
'RWXML: Insider version removed, Please reload VSCode.',
{
modal: false,
},
'Reload VSCode',
'Later'
)

if (res2 === 'Reload VSCode') {
await vscode.commands.executeCommand('workbench.action.reloadWindow')
} else {
return
}
} else if (res === 'No Thanks') {
return
} else {
// user canceled it
return
}
}

0 comments on commit e907eff

Please sign in to comment.