Skip to content

Commit

Permalink
chore: take ownership of the default launch types
Browse files Browse the repository at this point in the history
For #1065
  • Loading branch information
connor4312 committed Aug 3, 2021
1 parent beae729 commit bb134aa
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 172 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
{
"name": "Extension",
"type": "extensionHost",
"type": "pwa-extensionHost",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
Expand Down Expand Up @@ -173,4 +173,4 @@
]
}
]
}
}
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

This changelog records changes to stable releases since 1.50.2. "TBA" changes here may be available in the [nightly release](https://github.com/microsoft/vscode-js-debug/#nightly-extension) before they're in stable. Note that the minor version (`v1.X.0`) corresponds to the VS Code version js-debug is shipped in, but the patch version (`v1.50.X`) is not meaningful.

## Nightly
## v1.60 (August 2021)

### v1.60.0 - 2021-08-03

- chore: take ownership of the default launch types ([#1065](https://github.com/microsoft/vscode-js-debug/issues/1065))
- fix: apply electron updates for debugging vscode webviews ([ref](https://github.com/microsoft/vscode/issues/128637))

## v1.59 (July 2021)
Expand Down
16 changes: 0 additions & 16 deletions COMMON_PROBLEMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,3 @@ You launch your app, but the debugger doesn't connect to it. You're using an old
### Solution

We've seen some transient issues with early Node 10 point releases. To fix this we, recommend updating to a later Node 10 release (10.22.1 being the most recent at the time of writing), or to a newer version of Node altogether if nothing is keeping you on 10.

## My configuration property shows as invalid

### Symptoms

You're adding a configuration property to your launch.json, but it shows an invalid, even if it works.

### Solution

This can happen for newly introduced options. To fix this, you should prefix your launch type with `pwa-`, for example:

- `node` -> `pwa-node`
- `chrome` -> `pwa-chrome`
- `extensionHost` -> `pwa-extensionHost`

This is needed because the old configuration types are still "owned" by the old debuggers, and just redirect to this new debugger. While most additional options will be blindly passed along, they don't appear the old schemas and some may not work.
12 changes: 1 addition & 11 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const gulp = require('gulp');
const minimist = require('minimist');
const nls = require('vscode-nls-dev');
const path = require('path');
const replace = require('gulp-replace');
const sourcemaps = require('gulp-sourcemaps');
const tsb = require('gulp-tsb');
const rename = require('gulp-rename');
Expand Down Expand Up @@ -39,13 +38,6 @@ const distDir = 'dist';
const distSrcDir = `${distDir}/src`;
const nodeTargetsDir = `targets/node`;

/**
* If --drop-in is set, commands and debug types will be set to 'chrome' and
* 'node', rendering them incompatible with the base debuggers. Useful
* to only set this to true to publish, and develop as namespaced extensions.
*/
const namespace = process.argv.includes('--drop-in') ? '' : 'pwa-';

/**
* Whether we're running a nightly build.
*/
Expand Down Expand Up @@ -86,7 +78,6 @@ async function readJson(file) {
return JSON.parse(contents);
}

const replaceNamespace = () => replace(/NAMESPACE\((.*?)\)/g, `${namespace}$1`);
const tsProject = tsb.create('./tsconfig.json');

gulp.task('clean-assertions', () => del(['src/test/**/*.txt.actual']));
Expand All @@ -99,7 +90,6 @@ gulp.task('compile:ts', () =>
tsProject
.src()
.pipe(sourcemaps.init())
.pipe(replaceNamespace())
.pipe(tsProject())
.pipe(
sourcemaps.write('.', {
Expand Down Expand Up @@ -162,7 +152,7 @@ gulp.task('compile:dynamic', async () => {

gulp.task('compile:static', () =>
merge(
gulp.src(['LICENSE', 'package.json']).pipe(replaceNamespace()),
gulp.src(['LICENSE', 'package.json']),
gulp.src(['resources/**/*', 'README.md', 'src/**/*.sh'], { base: '.' }),
).pipe(gulp.dest(buildDir)),
);
Expand Down
80 changes: 0 additions & 80 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"description": "An extension for debugging Node.js programs and Chrome.",
"license": "MIT",
"engines": {
"vscode": "^1.58.0-insider",
"vscode": "^1.60.0-insider",
"node": ">=10"
},
"icon": "resources/logo.png",
Expand Down Expand Up @@ -136,7 +136,6 @@
"gulp": "^4.0.2",
"gulp-filter": "^7.0.0",
"gulp-rename": "^2.0.0",
"gulp-replace": "^1.1.3",
"gulp-sourcemaps": "^3.0.0",
"gulp-tsb": "^4.0.6",
"gulp-util": "^3.0.8",
Expand Down Expand Up @@ -184,7 +183,7 @@
{
"id": "jsBrowserBreakpoints",
"name": "Browser breakpoints",
"when": "debugConfigurationType == 'NAMESPACE(chrome)'"
"when": "debugConfigurationType == 'pwa-chrome'"
}
]
},
Expand Down
64 changes: 39 additions & 25 deletions src/build/generate-contributions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
Contributions,
DebugType,
IConfigurationTypes,
preferredDebugTypes,
} from '../common/contributionUtils';
import { knownToolToken } from '../common/knownTools';
import { mapValues, sortKeys, walkObject } from '../common/objUtils';
Expand Down Expand Up @@ -1038,39 +1039,50 @@ export const debuggers = [
function buildDebuggers() {
// eslint-disable-next-line
const output: any[] = [];
for (const d of debuggers) {
let entry = output.find(o => o.type === d.type);
if (!entry) {
// eslint-disable-next-line
const { request, configurationAttributes, required, defaults, ...rest } = d;
entry = {
...rest,
aiKey: appInsightsKey,
configurationAttributes: {},
configurationSnippets: [],
};
output.push(entry);
const ensureEntryForType = (type: string, d: typeof debuggers[0]) => {
let entry = output.find(o => o.type === type);
if (entry) {
return entry;
}

entry.configurationSnippets.push(...d.configurationSnippets);
entry.configurationAttributes[d.request] = {
required: d.required,
properties: mapValues(
d.configurationAttributes as { [key: string]: DescribedAttribute<unknown> },
({ docDefault: _, ...attrs }) => attrs,
),
// eslint-disable-next-line
const { request, configurationAttributes, required, defaults, ...rest } = d;
entry = {
...rest,
type,
aiKey: appInsightsKey,
configurationAttributes: {},
configurationSnippets: [],
};
output.push(entry);
return entry;
};

for (const d of debuggers) {
const primary = ensureEntryForType(d.type, d);
const entries = [primary];
const preferred = preferredDebugTypes.get(d.type);
if (preferred) {
entries.unshift(ensureEntryForType(preferred, d));
}

entries[0].configurationSnippets.push(...d.configurationSnippets);

for (const entry of entries) {
entry.configurationAttributes[d.request] = {
required: d.required,
properties: mapValues(
d.configurationAttributes as { [key: string]: DescribedAttribute<unknown> },
({ docDefault: _, ...attrs }) => attrs,
),
};
}
}

return walkObject(output, sortKeys);
}

const configurationSchema: ConfigurationAttributes<IConfigurationTypes> = {
[Configuration.UsePreviewDebugger]: {
type: 'boolean',
default: true,
description: refString('configuration.usePreview'),
},
[Configuration.NpmScriptLens]: {
enum: ['top', 'all', 'never'],
default: 'top',
Expand Down Expand Up @@ -1408,7 +1420,9 @@ if (require.main === module) {
},
activationEvents: [
...[...allCommands].map(cmd => `onCommand:${cmd}`),
...debuggers.map(dbg => `onDebugResolve:${dbg.type}`),
...[...debuggers.map(dbg => dbg.type), ...preferredDebugTypes.keys()].map(
t => `onDebugResolve:${t}`,
),
`onWebviewPanel:${Contributions.DiagnosticsView}`,
],
contributes: {
Expand Down
3 changes: 1 addition & 2 deletions src/build/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ const strings = {
'Where a "Run" and "Debug" code lens should be shown in your npm scripts. It may be on "all", scripts, on "top" of the script section, or "never".',
'configuration.terminalOptions':
'Default launch options for the JavaScript debug terminal and npm scripts.',
'configuration.usePreview': 'Use the new in-preview JavaScript debugger for Node.js and Chrome.',
'configuration.suggestPrettyPrinting':
'Whether to suggest pretty printing JavaScript code that looks minified when you step into it.',
'configuration.automaticallyTunnelRemoteServer':
Expand All @@ -297,7 +296,7 @@ const strings = {
'Auto attach to every Node.js process launched in the terminal.',
'configuration.autoAttachMode.disabled': 'Auto attach is disabled and not shown in status bar.',
'configuration.breakOnConditionalError':
'Whether to stop when conditional breakpoints throw an error. Note: your launch.json `type` must be prefixed with `pwa-` to use this, such as `pwa-node`.',
'Whether to stop when conditional breakpoints throw an error.',
'configuration.unmapMissingSources':
"Configures whether sourcemapped file where the original file can't be read will automatically be unmapped. If this is false (default), a prompt is shown.",
'configuration.defaultRuntimeExecutables':
Expand Down
19 changes: 12 additions & 7 deletions src/common/contributionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const enum Contributions {

export const enum Commands {
AddCustomBreakpoints = 'extension.js-debug.addCustomBreakpoints',
AttachProcess = 'extension.NAMESPACE(node-debug).attachNodeProcess',
AttachProcess = 'extension.pwa-node-debug.attachNodeProcess',
AutoAttachClearVariables = 'extension.js-debug.clearAutoAttachVariables',
AutoAttachSetVariables = 'extension.js-debug.setAutoAttachVariables',
AutoAttachToProcess = 'extension.js-debug.autoAttachToProcess',
Expand All @@ -41,12 +41,19 @@ export const enum Commands {
OpenEdgeDevTools = 'extension.js-debug.openEdgeDevTools',
}

export const preferredDebugTypes: ReadonlyMap<DebugType, string> = new Map([
[DebugType.Node, 'node'],
[DebugType.Chrome, 'chrome'],
[DebugType.ExtensionHost, 'extensionHost'],
[DebugType.Edge, 'msedge'],
]);

export const enum DebugType {
ExtensionHost = 'NAMESPACE(extensionHost)',
ExtensionHost = 'pwa-extensionHost',
Terminal = 'node-terminal',
Node = 'NAMESPACE(node)',
Chrome = 'NAMESPACE(chrome)',
Edge = 'NAMESPACE(msedge)',
Node = 'pwa-node',
Chrome = 'pwa-chrome',
Edge = 'pwa-msedge',
}

// constructing it this way makes sure we can't forget to add a type:
Expand Down Expand Up @@ -104,7 +111,6 @@ export const enum AutoAttachMode {
Always = 'always',
}
export const enum Configuration {
UsePreviewDebugger = 'debug.javascript.usePreview',
NpmScriptLens = 'debug.javascript.codelens.npmScripts',
TerminalDebugConfig = 'debug.javascript.terminalOptions',
PickAndAttachDebugOptions = 'debug.javascript.pickAndAttachOptions',
Expand All @@ -126,7 +132,6 @@ export type DebugByLinkState = 'on' | 'off' | 'always';
* Type map for {@link Configuration} properties.
*/
export interface IConfigurationTypes {
[Configuration.UsePreviewDebugger]: boolean;
[Configuration.NpmScriptLens]: 'all' | 'top' | 'never';
[Configuration.TerminalDebugConfig]: Partial<ITerminalLaunchConfiguration>;
[Configuration.PickAndAttachDebugOptions]: Partial<INodeAttachConfiguration>;
Expand Down
Loading

0 comments on commit bb134aa

Please sign in to comment.