Skip to content

Commit 1df97a5

Browse files
authored
feat(dev): "Show Global State" #2908
Problem: Toolkit developers, and customers who are troubleshooting, need a way to see the various global state that Toolkit depends on. Solution: Introduce `Show Global State` item in the "AWS (Developer)" menu. Currently only shows env vars, but can be expanded later.
1 parent 6e625ec commit 1df97a5

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "\"AWS (Developer)\" menu now includes a \"Show Global State\" item"
4+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@
10601060
},
10611061
{
10621062
"command": "aws.dev.openMenu",
1063-
"when": "aws.isDevMode"
1063+
"when": "aws.isDevMode || isCloud9"
10641064
}
10651065
],
10661066
"editor/title": [

src/dev/activation.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ interface MenuOption {
2121
}
2222

2323
/**
24-
* Currently contains all known developer tools.
24+
* Defines AWS Toolkit developer tools.
2525
*
2626
* Options are displayed as quick-pick items. The {@link MenuOption.executor} callback is ran
27-
* if the user selects an option. There is no support for name-spacing. Just add the relevant
27+
* on selection. There is no support for name-spacing. Just add the relevant
2828
* feature/module as a description so it can be moved around easier.
2929
*/
3030
const menuOptions: Record<string, MenuOption> = {
@@ -34,6 +34,22 @@ const menuOptions: Record<string, MenuOption> = {
3434
detail: 'Edit a key in global/secret storage as a JSON document',
3535
executor: openStorageFromInput,
3636
},
37+
showGlobalState: {
38+
label: 'Show Global State',
39+
description: 'AWS Toolkit',
40+
detail: 'Shows various state (including environment variables)',
41+
executor: showGlobalState,
42+
},
43+
}
44+
45+
export class GlobalStateDocumentProvider implements vscode.TextDocumentContentProvider {
46+
provideTextDocumentContent(uri: vscode.Uri): string {
47+
let s = 'Environment variables known to AWS Toolkit:\n'
48+
for (const [k, v] of Object.entries(process.env)) {
49+
s += `${k}=${v}\n`
50+
}
51+
return s
52+
}
3753
}
3854

3955
/**
@@ -53,7 +69,8 @@ export function activate(ctx: ExtContext): void {
5369

5470
ctx.extensionContext.subscriptions.push(
5571
devSettings.onDidChangeActiveSettings(updateMode),
56-
vscode.commands.registerCommand('aws.dev.openMenu', () => openMenu(ctx, menuOptions))
72+
vscode.commands.registerCommand('aws.dev.openMenu', () => openMenu(ctx, menuOptions)),
73+
vscode.workspace.registerTextDocumentContentProvider('aws-dev2', new GlobalStateDocumentProvider())
5774
)
5875

5976
updateMode()
@@ -228,4 +245,10 @@ async function openStorageFromInput() {
228245
}
229246
}
230247

248+
async function showGlobalState() {
249+
const uri = vscode.Uri.parse('aws-dev2:global-state')
250+
const doc = await vscode.workspace.openTextDocument(uri)
251+
await vscode.window.showTextDocument(doc, { preview: false })
252+
}
253+
231254
export const openStorageCommand = Commands.from(ObjectEditor).declareOpenStorage('_aws.dev.openStorage')

0 commit comments

Comments
 (0)