Skip to content

Commit c463160

Browse files
authored
Merge pull request #10 from gjsjohnmurray/prepare-0.0.4
README and CHANGELOG for 0.0.4 release
2 parents eabe54a + bbb9c32 commit c463160

File tree

2 files changed

+73
-26
lines changed

2 files changed

+73
-26
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.0.4 (24-Jul-2020)
2+
* Support storing passwords in local keychain.
3+
* Add API that other extensions can use.
4+
* Improve README.
5+
16
## 0.0.3 (02-Jul-2020)
27
* Change publisher id to `intersystems-community`.
38
* Disallow uppercase in server names.

README.md

Lines changed: 68 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,87 @@
11
# InterSystems® Server Manager
2-
A VS Code helper extension that contributes settings which define connections to InterSystems servers.
2+
This is a VS Code helper extension that contributes settings which define connections to [InterSystems](https://www.intersystems.com/) servers.
33

44
For example:
55
```json
6-
"intersystems.servers": {
7-
"my-local": {
8-
"webServer": {
9-
"scheme": "http",
10-
"host": "127.0.0.1",
11-
"port": 52773
12-
},
13-
"description": "My local IRIS instance"
6+
"intersystems.servers": {
7+
"dev": {
8+
"webServer": {
9+
"scheme": "https",
10+
"host": "webhost.local",
11+
"port": 443,
12+
"pathPrefix": "iris/dev"
1413
},
15-
"dev": {
16-
"webServer": {
17-
"scheme": "https",
18-
"host": "webhost.local",
19-
"port": 443,
20-
"pathPrefix": "iris/dev"
21-
},
22-
"username": "alice",
23-
"description": "Development server serviced by central web host over HTTPS"
14+
"username": "alice",
15+
"description": "Development server serviced by central web host over HTTPS"
16+
},
17+
"my-local": {
18+
"webServer": {
19+
"scheme": "http",
20+
"host": "127.0.0.1",
21+
"port": 52773
2422
},
25-
"/default": "my-local"
26-
}
23+
"description": "My local IRIS instance"
24+
},
25+
"/default": "my-local"
26+
}
2727
```
2828

29-
An extension XYZ needing to connect to InterSystems servers defines this extension as a dependency in its `package.json`
29+
This extension helps users add server definitions to their [user or workspace settings](https://code.visualstudio.com/docs/getstarted/settings) by editing JSON files.
30+
31+
It adds the command `InterSystems Server Manager: Store Password in Keychain` to the Command Palette, which offers a quickpick of defined servers, then prompts for a password to store. This facility should be used instead of the plaintext `password` property of a server's definition, which has been deprecated.
32+
33+
A command `InterSystems Server Manager: Clear Password from Keychain` removes a stored password.
34+
35+
## Use By Other Extensions
36+
37+
An extension XYZ needing to connect to InterSystems servers can define this extension as a dependency in its `package.json`
3038

3139
```json
3240
"extensionDependencies": [
3341
"intersystems-community.servermanager"
3442
],
3543
```
3644

37-
This helps users add server definitions to their [user or workspace settings](https://code.visualstudio.com/docs/getstarted/settings).
45+
Alternatively the `activate` method of XYZ can detect if the extension is already available, then offer to install it if necessary:
46+
47+
```ts
48+
const extId = "intersystems-community.servermanager";
49+
let extension = vscode.extensions.getExtension(extId);
50+
if (!extension) {
51+
// Optionally ask user for permission
52+
// ...
53+
54+
await vscode.commands.executeCommand("workbench.extensions.installExtension", extId);
55+
extension = vscode.extensions.getExtension(extId);
56+
}
57+
if (!extension.isActive) {
58+
await extension.activate();
59+
}
60+
```
3861

39-
Extension XYZ then gets the `intersystems.servers` object and uses it as needed, for example:
62+
XYZ can then use the extension's API to obtain the properties of a named server definition, including the password from the keychain if present:
4063

4164
```ts
42-
const allServers = vscode.workspace.getConfiguration('intersystems').get('servers');
43-
const mine = allServers['my-server'];
44-
const webHost = mine.webServer.host;
65+
const serverManagerApi = extension.exports;
66+
if (serverManagerApi && serverManagerApi.getServerSpec) { // defensive coding
67+
const serverSpec = await serverManagerApi.getServerSpec(serverName);
68+
}
4569
```
70+
71+
If the `username` property is absent it will be prompted for. If no `password` is stored in the keychain or in the JSON definition the user will be asked to provide this the first time in any session that `getServerSpec` is called for a given server.
72+
73+
To offer the user a quickpick of servers:
74+
75+
```ts
76+
const serverName = await serverManagerApi.pickServer();
77+
```
78+
79+
To obtain an array of server names:
80+
81+
```ts
82+
const allServerNames = await serverManagerApi.getServerNames();
83+
```
84+
85+
Servers are usually listed in the order they are defined. The exception is that if a server name is set as the value of the `/default` property (see example above) it will be shown first in the list.
86+
87+
For details of the API, including result types and available parameters, review the source code of the extension's `activate` method [here](https://github.com/intersystems-community/intersystems-servermanager/blob/master/src/extension.ts).

0 commit comments

Comments
 (0)