Remove Node.js walkthrough/getting started guide (#176325)
Remove Node.js walkthrough/getting started. Co-authored-by: Matt Bierner <matb@microsoft.com>
This commit is contained in:
Родитель
0e48e291fd
Коммит
93026118c5
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 5.8 KiB |
|
@ -1562,59 +1562,6 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"walkthroughs": [
|
||||
{
|
||||
"id": "nodejsWelcome",
|
||||
"title": "%walkthroughs.nodejsWelcome.title%",
|
||||
"icon": "media/nodejsWalkthroughIcon.png",
|
||||
"description": "%walkthroughs.nodejsWelcome.description%",
|
||||
"when": "false",
|
||||
"steps": [
|
||||
{
|
||||
"id": "walkthroughs.nodejsWelcome.downloadNode.forMacOrWindows",
|
||||
"title": "%walkthroughs.nodejsWelcome.downloadNode.forMacOrWindows.title%",
|
||||
"description": "%walkthroughs.nodejsWelcome.downloadNode.forMacOrWindows.description%",
|
||||
"media": {
|
||||
"svg": "resources/walkthroughs/install-node-js.svg"
|
||||
},
|
||||
"when": "isWindows || isMac"
|
||||
},
|
||||
{
|
||||
"id": "walkthroughs.nodejsWelcome.downloadNode.forLinux",
|
||||
"title": "%walkthroughs.nodejsWelcome.downloadNode.forLinux.title%",
|
||||
"description": "%walkthroughs.nodejsWelcome.downloadNode.forLinux.description%",
|
||||
"media": {
|
||||
"svg": "resources/walkthroughs/install-node-js.svg"
|
||||
},
|
||||
"when": "isLinux"
|
||||
},
|
||||
{
|
||||
"id": "walkthroughs.nodejsWelcome.makeJsFile",
|
||||
"title": "%walkthroughs.nodejsWelcome.makeJsFile.title%",
|
||||
"description": "%walkthroughs.nodejsWelcome.makeJsFile.description%",
|
||||
"media": {
|
||||
"svg": "resources/walkthroughs/create-a-js-file.svg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "walkthroughs.nodejsWelcome.debugJsFile",
|
||||
"title": "%walkthroughs.nodejsWelcome.debugJsFile.title%",
|
||||
"description": "%walkthroughs.nodejsWelcome.debugJsFile.description%",
|
||||
"media": {
|
||||
"svg": "resources/walkthroughs/debug-and-run.svg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "walkthroughs.nodejsWelcome.learnMoreAboutJs",
|
||||
"title": "%walkthroughs.nodejsWelcome.learnMoreAboutJs.title%",
|
||||
"description": "%walkthroughs.nodejsWelcome.learnMoreAboutJs.description%",
|
||||
"media": {
|
||||
"svg": "resources/walkthroughs/learn-more.svg"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
|
|
|
@ -18,7 +18,7 @@ export class ExperimentationService {
|
|||
|
||||
constructor(telemetryReporter: IExperimentationTelemetryReporter, id: string, version: string, globalState: vscode.Memento) {
|
||||
this._telemetryReporter = telemetryReporter;
|
||||
this._experimentationServicePromise = createExperimentationService(this._telemetryReporter, id, version, globalState);
|
||||
this._experimentationServicePromise = createTasExperimentationService(this._telemetryReporter, id, version, globalState);
|
||||
}
|
||||
|
||||
public async getTreatmentVariable<K extends keyof ExperimentTypes>(name: K, defaultValue: ExperimentTypes[K]): Promise<ExperimentTypes[K]> {
|
||||
|
@ -32,7 +32,7 @@ export class ExperimentationService {
|
|||
}
|
||||
}
|
||||
|
||||
export async function createExperimentationService(
|
||||
export async function createTasExperimentationService(
|
||||
reporter: IExperimentationTelemetryReporter,
|
||||
id: string,
|
||||
version: string,
|
||||
|
|
|
@ -17,7 +17,6 @@ import { NodeLogDirectoryProvider } from './tsServer/logDirectoryProvider.electr
|
|||
import { ElectronServiceProcessFactory } from './tsServer/serverProcess.electron';
|
||||
import { DiskTypeScriptVersionProvider } from './tsServer/versionProvider.electron';
|
||||
import { ActiveJsTsEditorTracker } from './ui/activeJsTsEditorTracker';
|
||||
import { JsWalkthroughState, registerJsNodeWalkthrough } from './ui/jsNodeWalkthrough.electron';
|
||||
import { ElectronServiceConfigurationProvider } from './configuration/configuration.electron';
|
||||
import { onCaseInsensitiveFileSystem } from './utils/fs.electron';
|
||||
import { Logger } from './logging/logger';
|
||||
|
@ -43,9 +42,6 @@ export function activate(
|
|||
const activeJsTsEditorTracker = new ActiveJsTsEditorTracker();
|
||||
context.subscriptions.push(activeJsTsEditorTracker);
|
||||
|
||||
const jsWalkthroughState = new JsWalkthroughState();
|
||||
context.subscriptions.push(jsWalkthroughState);
|
||||
|
||||
let experimentTelemetryReporter: IExperimentationTelemetryReporter | undefined;
|
||||
const packageInfo = getPackageInfo(context);
|
||||
if (packageInfo) {
|
||||
|
@ -77,7 +73,6 @@ export function activate(
|
|||
});
|
||||
|
||||
registerBaseCommands(commandManager, lazyClientHost, pluginManager, activeJsTsEditorTracker);
|
||||
registerJsNodeWalkthrough(commandManager, jsWalkthroughState);
|
||||
|
||||
import('./task/taskProvider').then(module => {
|
||||
context.subscriptions.push(module.register(lazyClientHost.map(x => x.serviceClient)));
|
||||
|
|
|
@ -1,198 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as cp from 'child_process';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { CommandManager } from '../commands/commandManager';
|
||||
import { Disposable } from '../utils/dispose';
|
||||
|
||||
|
||||
export async function nodeWasResolvable(): Promise<boolean> {
|
||||
let execStr: string;
|
||||
switch (process.platform) {
|
||||
case 'win32':
|
||||
execStr = 'where node';
|
||||
break;
|
||||
case 'aix':
|
||||
case 'cygwin':
|
||||
case 'darwin':
|
||||
case 'freebsd':
|
||||
case 'haiku':
|
||||
case 'linux':
|
||||
case 'netbsd':
|
||||
case 'openbsd':
|
||||
case 'sunos':
|
||||
execStr = 'which node';
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return new Promise(resolve => {
|
||||
cp.exec(execStr, { windowsHide: true }, err => {
|
||||
resolve(!err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export class JsWalkthroughState extends Disposable {
|
||||
exampleJsDocument: vscode.TextDocument | undefined = undefined;
|
||||
|
||||
override dispose() {
|
||||
this.exampleJsDocument = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export class CreateNewJSFileCommand {
|
||||
public static readonly id = 'javascript-walkthrough.commands.createJsFile';
|
||||
public readonly id = CreateNewJSFileCommand.id;
|
||||
|
||||
constructor(
|
||||
private readonly walkthroughState: JsWalkthroughState
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
createNewJSFile(this.walkthroughState);
|
||||
}
|
||||
}
|
||||
|
||||
export class DebugJsFileCommand {
|
||||
public static readonly id = 'javascript-walkthrough.commands.debugJsFile';
|
||||
public readonly id = DebugJsFileCommand.id;
|
||||
|
||||
constructor(
|
||||
private readonly walkthroughState: JsWalkthroughState
|
||||
) { }
|
||||
|
||||
public execute() {
|
||||
debugJsFile(this.walkthroughState);
|
||||
}
|
||||
}
|
||||
|
||||
export class NodeInstallationFoundCommand {
|
||||
public static readonly id = 'javascript-walkthrough.commands.nodeInstallationFound';
|
||||
public readonly id = NodeInstallationFoundCommand.id;
|
||||
public execute() { }
|
||||
}
|
||||
|
||||
async function createNewJSFile(walkthroughState: JsWalkthroughState) {
|
||||
const newFile = await vscode.workspace.openTextDocument({
|
||||
language: 'javascript',
|
||||
content: `// Write a message to the console.\nconsole.log('hello world!');\n`,
|
||||
});
|
||||
walkthroughState.exampleJsDocument = newFile;
|
||||
return vscode.window.showTextDocument(newFile, vscode.ViewColumn.Beside);
|
||||
}
|
||||
|
||||
async function debugJsFile(walkthroughState: JsWalkthroughState) {
|
||||
const hasNode = await nodeWasResolvable();
|
||||
if (!hasNode) {
|
||||
const reloadResponse = vscode.l10n.t("Reload VS Code");
|
||||
const debugAnywayResponse = vscode.l10n.t("Try Debugging Anyway");
|
||||
const dismissResponse = vscode.l10n.t("Dismiss");
|
||||
const response = await vscode.window.showErrorMessage(
|
||||
// The message
|
||||
vscode.l10n.t("We couldn\'t find Node.js on this computer. If you just installed it, you might need to reload VS Code."),
|
||||
// The options
|
||||
reloadResponse,
|
||||
debugAnywayResponse,
|
||||
dismissResponse,
|
||||
);
|
||||
|
||||
if (response === undefined || response === dismissResponse) {
|
||||
return;
|
||||
}
|
||||
if (response === reloadResponse) {
|
||||
vscode.commands.executeCommand('workbench.action.reloadWindow');
|
||||
return;
|
||||
}
|
||||
}
|
||||
tryDebugRelevantDocument(walkthroughState.exampleJsDocument, 'javascript', ['.mjs', '.js'], () => createNewJSFile(walkthroughState));
|
||||
}
|
||||
|
||||
type DocSearchResult =
|
||||
| { kind: 'visible'; editor: vscode.TextEditor }
|
||||
| { kind: 'hidden'; uri: vscode.Uri }
|
||||
| { kind: 'not-found' };
|
||||
|
||||
async function tryDebugRelevantDocument(lastDocument: vscode.TextDocument | undefined, languageId: string, languageExtensions: [string, ...string[]], createFileAndFocus: () => Promise<vscode.TextEditor>): Promise<void> {
|
||||
let searchResult!: DocSearchResult;
|
||||
for (const languageExtension of languageExtensions) {
|
||||
searchResult = tryFindRelevantDocument(lastDocument, languageId, languageExtension);
|
||||
if (searchResult.kind !== 'not-found') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let editor: vscode.TextEditor;
|
||||
// If not, make one.
|
||||
switch (searchResult.kind) {
|
||||
case 'visible':
|
||||
// Focus if necessary.
|
||||
editor = searchResult.editor;
|
||||
if (vscode.window.activeTextEditor !== editor) {
|
||||
await vscode.window.showTextDocument(editor.document, {
|
||||
viewColumn: vscode.ViewColumn.Beside,
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'hidden':
|
||||
editor = await vscode.window.showTextDocument(searchResult.uri, {
|
||||
viewColumn: vscode.ViewColumn.Beside,
|
||||
});
|
||||
break;
|
||||
case 'not-found':
|
||||
editor = await createFileAndFocus();
|
||||
break;
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
vscode.commands.executeCommand('workbench.action.debug.start'),
|
||||
vscode.commands.executeCommand('workbench.debug.action.focusRepl'),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/** Tries to find a relevant {@link vscode.TextEditor} or a {@link vscode.Uri} for an open document */
|
||||
function tryFindRelevantDocument(lastDocument: vscode.TextDocument | undefined, languageId: string, languageExtension: string): DocSearchResult {
|
||||
let editor: vscode.TextEditor | undefined;
|
||||
|
||||
// Try to find the document created from the last step.
|
||||
if (lastDocument) {
|
||||
editor = vscode.window.visibleTextEditors.find(editor => editor.document === lastDocument);
|
||||
}
|
||||
|
||||
// If we couldn't find that, find a visible document with the desired language.
|
||||
editor ??= vscode.window.visibleTextEditors.find(editor => editor.document.languageId === languageId);
|
||||
if (editor) {
|
||||
return {
|
||||
kind: 'visible',
|
||||
editor,
|
||||
};
|
||||
}
|
||||
|
||||
// If we still couldn't find that, find a possibly not-visible document.
|
||||
for (const tabGroup of vscode.window.tabGroups.all) {
|
||||
for (const tab of tabGroup.tabs) {
|
||||
if (tab.input instanceof vscode.TabInputText && tab.input.uri.path.endsWith(languageExtension)) {
|
||||
return {
|
||||
kind: 'hidden',
|
||||
uri: tab.input.uri,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { kind: 'not-found' };
|
||||
}
|
||||
|
||||
export function registerJsNodeWalkthrough(
|
||||
commandManager: CommandManager,
|
||||
jsWalkthroughState: JsWalkthroughState,
|
||||
) {
|
||||
commandManager.register(new CreateNewJSFileCommand(jsWalkthroughState));
|
||||
commandManager.register(new DebugJsFileCommand(jsWalkthroughState));
|
||||
}
|
Загрузка…
Ссылка в новой задаче