Skip to content

Commit 5fe9913

Browse files
Merge pull request #13 from gjsjohnmurray/fix-12
fix #12 add onDidChangePassword event to API and remove test commands
2 parents 3a7c22c + fd0bb66 commit 5fe9913

File tree

5 files changed

+30
-76
lines changed

5 files changed

+30
-76
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.0.5 (21-Aug-2020)
2+
* Add onDidChangePassword to API.
3+
* Remove test commands, which are now provided by our `intersystems-community.vscode-extension-api-tester` extension.
4+
15
## 0.0.4 (24-Jul-2020)
26
* Support storing passwords in local keychain.
37
* Add API that other extensions can use.

package.json

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@
5858
},
5959
"main": "./out/extension",
6060
"activationEvents": [
61-
"onCommand:intersystems-community.servermanager.testPickServer",
62-
"onCommand:intersystems-community.servermanager.testPickServerFlushingCachedCredentials",
63-
"onCommand:intersystems-community.servermanager.testPickServerDetailed",
6461
"onCommand:intersystems-community.servermanager.storePassword",
6562
"onCommand:intersystems-community.servermanager.clearPassword"
6663
],
@@ -192,21 +189,6 @@
192189
"command": "intersystems-community.servermanager.clearPassword",
193190
"category": "InterSystems Server Manager",
194191
"title": "Clear Password from Keychain"
195-
},
196-
{
197-
"command": "intersystems-community.servermanager.testPickServer",
198-
"category": "InterSystems Server Manager",
199-
"title": "Test Server Selection"
200-
},
201-
{
202-
"command": "intersystems-community.servermanager.testPickServerFlushingCachedCredentials",
203-
"category": "InterSystems Server Manager",
204-
"title": "Test Server Selection (flush cached credentials)"
205-
},
206-
{
207-
"command": "intersystems-community.servermanager.testPickServerDetailed",
208-
"category": "InterSystems Server Manager",
209-
"title": "Test Server Selection with Details"
210192
}
211193
]
212194
}

src/commands/managePasswords.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { extensionId } from '../extension';
33
import { Keychain } from '../keychain';
44
import { credentialCache } from '../api/getServerSpec';
55

6-
export async function storePassword() {
6+
export async function storePassword(): Promise<string> {
77
const name = await commonPickServer({matchOnDetail: true});
8+
let reply = '';
89
if (name) {
910
await vscode.window
1011
.showInputBox({
@@ -22,13 +23,15 @@ export async function storePassword() {
2223
new Keychain(name).setPassword(password).then(() => {
2324
vscode.window.showInformationMessage(`Password for '${name}' stored in keychain.`);
2425
});
26+
reply = name;
2527
}
2628
})
27-
2829
}
30+
return reply;
2931
}
3032

31-
export async function clearPassword() {
33+
export async function clearPassword(): Promise<string> {
34+
let reply = '';
3235
const name = await commonPickServer({matchOnDetail: true});
3336
if (name) {
3437
credentialCache[name] = undefined;
@@ -37,10 +40,12 @@ export async function clearPassword() {
3740
vscode.window.showWarningMessage(`No password for '${name}' found in keychain.`);
3841
} else if (await keychain.deletePassword()) {
3942
vscode.window.showInformationMessage(`Password for '${name}' removed from keychain.`);
43+
reply = name;
4044
} else {
4145
vscode.window.showWarningMessage(`Failed to remove password for '${name}' from keychain.`);
4246
}
4347
}
48+
return reply;
4449
}
4550

4651
async function commonPickServer(options?: vscode.QuickPickOptions): Promise<string | undefined> {

src/commands/testPickServer.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/extension.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
export const extensionId = 'intersystems-community.servermanager';
33

44
import * as vscode from 'vscode';
5-
import { testPickServer, testPickServerWithoutCachedCredentials as testPickServerFlushingCachedCredentials, testPickServerDetailed } from './commands/testPickServer';
65
import { pickServer } from './api/pickServer';
76
import { getServerNames } from './api/getServerNames';
87
import { getServerSpec } from './api/getServerSpec';
@@ -31,32 +30,27 @@ export interface ServerSpec {
3130

3231
export function activate(context: vscode.ExtensionContext) {
3332

33+
const _onDidChangePassword = new vscode.EventEmitter<string>();
3434

35-
// Register the commands
35+
// Register the commands
3636
context.subscriptions.push(
3737
vscode.commands.registerCommand(`${extensionId}.storePassword`, () => {
38-
storePassword();
38+
storePassword()
39+
.then((name) => {
40+
if (name && name.length > 0) {
41+
_onDidChangePassword.fire(name);
42+
}
43+
});
3944
})
4045
);
4146
context.subscriptions.push(
4247
vscode.commands.registerCommand(`${extensionId}.clearPassword`, () => {
43-
clearPassword();
44-
})
45-
);
46-
47-
context.subscriptions.push(
48-
vscode.commands.registerCommand(`${extensionId}.testPickServer`, () => {
49-
testPickServer();
50-
})
51-
);
52-
context.subscriptions.push(
53-
vscode.commands.registerCommand(`${extensionId}.testPickServerFlushingCachedCredentials`, () => {
54-
testPickServerFlushingCachedCredentials();
55-
})
56-
);
57-
context.subscriptions.push(
58-
vscode.commands.registerCommand(`${extensionId}.testPickServerDetailed`, () => {
59-
testPickServerDetailed();
48+
clearPassword()
49+
.then((name) => {
50+
if (name && name.length > 0) {
51+
_onDidChangePassword.fire(name);
52+
}
53+
});
6054
})
6155
);
6256

@@ -71,6 +65,10 @@ export function activate(context: vscode.ExtensionContext) {
7165

7266
async getServerSpec(name: string, scope?: vscode.ConfigurationScope, flushCredentialCache: boolean = false): Promise<ServerSpec | undefined> {
7367
return await getServerSpec(name, scope, flushCredentialCache);
68+
},
69+
70+
onDidChangePassword(): vscode.Event<string> {
71+
return _onDidChangePassword.event;
7472
}
7573

7674
};

0 commit comments

Comments
 (0)