Skip to content

Commit 9447d1d

Browse files
feat(codecatalyst): show README.md on first connect #3340
* Show the README.md when connecting to a devenv for the first time. * Don't do this on Cloud9, because it shows a "third-party content" warning. Signed-off-by: Nikolas Komonen <[email protected]>
1 parent 37f7ede commit 9447d1d

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
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": "CodeCatalyst: show readme on first load of a Dev Environment"
4+
}

src/codecatalyst/activation.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export async function activate(ctx: ExtContext): Promise<void> {
7575
return
7676
}
7777

78+
await showReadmeFileOnFirstLoad(ctx.extensionContext.workspaceState)
79+
7880
const settings = PromptSettings.instance
7981
if (await settings.isPromptEnabled('remoteConnected')) {
8082
const message = localize(
@@ -96,3 +98,39 @@ export async function activate(ctx: ExtContext): Promise<void> {
9698
authProvider.removeSavedConnection()
9799
})
98100
}
101+
102+
async function showReadmeFileOnFirstLoad(workspaceState: vscode.ExtensionContext['workspaceState']): Promise<void> {
103+
if (isCloud9()) {
104+
return
105+
}
106+
107+
getLogger().info('codecatalyst: showReadmeFileOnFirstLoad()')
108+
// Check dev env state to see if this is the first time the user has connected to a dev env
109+
const isFirstLoad = workspaceState.get('aws.codecatalyst.devEnv.isFirstLoad', true)
110+
111+
if (!isFirstLoad) {
112+
getLogger().info('codecatalyst: is not first load, skipping showing README.md')
113+
return
114+
}
115+
116+
// Determine expected readme file location
117+
const readmePath = `README.md`
118+
119+
// Find readme file in workspace
120+
const readmeUri = await vscode.workspace.findFiles(readmePath).then(files => {
121+
if (files.length === 0) {
122+
return undefined
123+
}
124+
return files[0]
125+
})
126+
127+
if (readmeUri === undefined) {
128+
getLogger().info(`codecatalyst: README.md not found in path '${readmePath}'`)
129+
return
130+
}
131+
132+
// Show rendered readme file to user
133+
await vscode.commands.executeCommand('markdown.showPreview', readmeUri)
134+
135+
await workspaceState.update('aws.codecatalyst.devEnv.isFirstLoad', false)
136+
}

0 commit comments

Comments
 (0)