-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interactive documentation for side panel #351
Changes from 7 commits
7e01c8e
1ba9462
e84d3f6
d7e9932
f34959a
6dc6f93
01ca238
656bba6
262a176
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,18 @@ | |
"command": "vscode-edge-devtools-view.viewChangelog", | ||
"category": "Microsoft Edge Tools", | ||
"title": "View Changelog" | ||
}, | ||
{ | ||
"command": "vscode-edge-devtools-view.configureLaunchJson", | ||
"category": "Microsoft Edge Tools", | ||
"enablement": "titleCommandsRegistered", | ||
"title": "Configure launch.json file" | ||
}, | ||
{ | ||
"command": "vscode-edge-devtools-view.launchProject", | ||
"category": "Microsoft Edge Tools", | ||
"enablement": "titleCommandsRegistered", | ||
"title": "Launch project" | ||
} | ||
], | ||
"configuration": { | ||
|
@@ -516,7 +528,39 @@ | |
"name": "Targets" | ||
} | ||
] | ||
} | ||
}, | ||
"viewsWelcome": [ | ||
{ | ||
"view": "vscode-edge-devtools-view.targets", | ||
"contents": "Launch an instance of Microsoft Edge to begin inspecting and modifying webpages.\n[Launch Instance](command:vscode-edge-devtools-view.launch)", | ||
"when": "titleCommandsRegistered && launchJsonStatus != Supported" | ||
}, | ||
{ | ||
"view": "vscode-edge-devtools-view.targets", | ||
"contents": "To customize your launch experience, [open a folder](command:vscode.openFolder) and create a launch.json file.", | ||
"when": "titleCommandsRegistered && workbenchState == empty" | ||
}, | ||
{ | ||
"view": "vscode-edge-devtools-view.targets", | ||
"contents": "Customize your launch experience by adding a launch.json file to your project.\n[Generate launch.json](command:vscode-edge-devtools-view.configureLaunchJson)", | ||
"when": "titleCommandsRegistered && workbenchState != empty && launchJsonStatus == None" | ||
}, | ||
{ | ||
"view": "vscode-edge-devtools-view.targets", | ||
"contents": "Customize your launch experience by adding a debug configuration to your launch.json file.\n[Configure launch.json](command:vscode-edge-devtools-view.configureLaunchJson)", | ||
"when": "titleCommandsRegistered && launchJsonStatus == Unsupported" | ||
}, | ||
{ | ||
"view": "vscode-edge-devtools-view.targets", | ||
"contents": "Launch an instance of Microsoft Edge to begin inspecting and modifying your site.\n[Launch Project](command:vscode-edge-devtools-view.launchProject)", | ||
"when": "titleCommandsRegistered && launchJsonStatus == Supported" | ||
}, | ||
{ | ||
"view": "vscode-edge-devtools-view.targets", | ||
"contents": "If you have any questions or want to learn more, check the [docs on GitHub](https://github.com/microsoft/vscode-edge-devtools/blob/master/README.md)", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will add a period at the end of this sentence when I go to address feedback |
||
"when": "titleCommandsRegistered" | ||
} | ||
] | ||
}, | ||
"jest": { | ||
"transform": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,12 @@ export const SETTINGS_DEFAULT_SOURCE_MAPS = true; | |
export const SETTINGS_DEFAULT_EDGE_DEBUGGER_PORT = 2015; | ||
export const SETTINGS_DEFAULT_ATTACH_TIMEOUT = 10000; | ||
export const SETTINGS_DEFAULT_ATTACH_INTERVAL = 200; | ||
export const providedDebugConfig: vscode.DebugConfiguration = { | ||
name: "Launch Microsoft Edge and open the Edge DevTools", | ||
request: "launch", | ||
type: `${SETTINGS_STORE_NAME}.debug`, | ||
url: "http://localhost:8080", | ||
}; | ||
|
||
const WIN_APP_DATA = process.env.LOCALAPPDATA || "/"; | ||
const msEdgeBrowserMapping: Map<BrowserFlavor, IBrowserPath> = new Map(); | ||
|
@@ -284,6 +290,61 @@ export async function getBrowserPath(config: Partial<IUserConfig> = {}): Promise | |
} | ||
} | ||
|
||
/** | ||
* Gets a supported debug config and updates the status of the launch.json file associated with the current workspace | ||
* @returns {vscode.DebugConfiguration | null} | ||
*/ | ||
export function getLaunchJson(): vscode.DebugConfiguration | null { | ||
// Check if there is a folder open | ||
if (!vscode.workspace.workspaceFolders) { | ||
vscode.commands.executeCommand('setContext', 'launchJsonStatus', "None"); | ||
return null; | ||
} | ||
|
||
// Check if there's a launch.json file | ||
const workspaceUri = vscode.workspace.workspaceFolders[0].uri; | ||
const filePath = `${workspaceUri.fsPath}/.vscode/launch.json`; | ||
if (fse.pathExistsSync(filePath)) { | ||
// Check if there is a supported debug config | ||
const configs = vscode.workspace.getConfiguration('launch', workspaceUri).get('configurations') as vscode.DebugConfiguration[]; | ||
for (const config of configs) { | ||
if (config.type === 'vscode-edge-devtools.debug' || config.type === 'msedge' || config.type === 'edge') { | ||
vscode.commands.executeCommand('setContext', 'launchJsonStatus', "Supported"); | ||
return config; | ||
} | ||
} | ||
vscode.commands.executeCommand('setContext', 'launchJsonStatus', "Unsupported"); | ||
return null; | ||
} else { | ||
vscode.commands.executeCommand('setContext', 'launchJsonStatus', "None"); | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* Add a template for a supported debug configuration to launch.json | ||
* @returns {void} | ||
*/ | ||
export function configureLaunchJson(): void { | ||
if (!vscode.workspace.workspaceFolders) | ||
return; | ||
|
||
// Create ./.vscode/launch.json if it doesn't already exist | ||
const workspaceUri = vscode.workspace.workspaceFolders[0].uri; | ||
fse.ensureFileSync(`${workspaceUri.fsPath}/.vscode/launch.json`); | ||
|
||
// Append a supported debug config to their list of configurations | ||
const launchJson = vscode.workspace.getConfiguration('launch', workspaceUri); | ||
let configs = launchJson.get('configurations') as vscode.DebugConfiguration[]; | ||
let configWithInstruction = {...providedDebugConfig}; | ||
configWithInstruction.url += ' **Replace with your website url before launching**'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be a cleaner experience if we instead default to the new startpage in the generated launch.json, and leave a comment after the url that contains this text. That way, the generated launch.json is valid without any edits? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would depend on #350 . Or we could default to the localhost link for now and I could update my PR if this lands first |
||
configs.push(configWithInstruction); | ||
|
||
// Update launch.json with new configuration list and open in editor | ||
launchJson.update('configurations', configs); | ||
vscode.commands.executeCommand('vscode.open', vscode.Uri.joinPath(workspaceUri, '/.vscode/launch.json')); | ||
} | ||
|
||
/** | ||
* Launch the specified browser with remote debugging enabled | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should show all the content for the empty target list immediately and not wait on the
titleCommandsRegistered
flag. We can disable the buttons that actually launch commands until they're ready with theenablement
flag when the commands are registered.