From 57fb93891d085cf2505096f7210787db43d4d150 Mon Sep 17 00:00:00 2001 From: chriswang521 Date: Fri, 21 Jun 2024 13:42:33 +0800 Subject: [PATCH] =?UTF-8?q?fixed:=E7=A7=BB=E9=99=A4=E6=97=A0=E6=95=88?= =?UTF-8?q?=E7=9A=84=E5=91=BD=E4=BB=A4=E8=A1=8C=E5=B7=A5=E5=85=B7=E4=B8=AD?= =?UTF-8?q?tunnel=E5=92=8Cserve=E5=91=BD=E4=BB=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/vs/code/node/cli.ts | 59 +++++++++++---------- src/vs/platform/environment/common/argv.ts | 18 +++---- src/vs/platform/environment/node/argv.ts | 60 +++++++++++----------- 3 files changed, 68 insertions(+), 69 deletions(-) diff --git a/src/vs/code/node/cli.ts b/src/vs/code/node/cli.ts index b8995c79..2a774c6f 100644 --- a/src/vs/code/node/cli.ts +++ b/src/vs/code/node/cli.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ChildProcess, spawn, SpawnOptions, StdioOptions } from 'child_process'; +import { ChildProcess, spawn, SpawnOptions } from 'child_process'; import { chmodSync, existsSync, readFileSync, statSync, truncateSync, unlinkSync } from 'fs'; import { homedir, release, tmpdir } from 'os'; import type { ProfilingSession, Target } from 'v8-inspect-profiler'; @@ -15,7 +15,7 @@ import { whenDeleted, writeFileSync } from 'vs/base/node/pfs'; import { findFreePort } from 'vs/base/node/ports'; import { watchFileContents } from 'vs/platform/files/node/watcher/nodejs/nodejsWatcherLib'; import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; -import { buildHelpMessage, buildVersionMessage, NATIVE_CLI_COMMANDS, OPTIONS } from 'vs/platform/environment/node/argv'; +import { buildHelpMessage, buildVersionMessage, OPTIONS } from 'vs/platform/environment/node/argv'; import { addArg, parseCLIProcessArgv } from 'vs/platform/environment/node/argvHelper'; import { getStdinFilePath, hasStdinWithoutTty, readFromStdin, stdinDataListener } from 'vs/platform/environment/node/stdin'; import { createWaitMarkerFileSync } from 'vs/platform/environment/node/wait'; @@ -24,7 +24,6 @@ import { CancellationTokenSource } from 'vs/base/common/cancellation'; import { isUNC, randomPath } from 'vs/base/common/extpath'; import { Utils } from 'vs/platform/profiling/common/profiling'; import { FileAccess } from 'vs/base/common/network'; -import { cwd } from 'vs/base/common/process'; import { addUNCHostToAllowlist } from 'vs/base/node/unc'; import { URI } from 'vs/base/common/uri'; @@ -51,34 +50,34 @@ export async function main(argv: string[]): Promise { return; } - for (const subcommand of NATIVE_CLI_COMMANDS) { - if (args[subcommand]) { - if (!product.tunnelApplicationName) { - console.error(`'${subcommand}' command not supported in ${product.applicationName}`); - return; - } - const tunnelArgs = argv.slice(argv.indexOf(subcommand) + 1); // all arguments behind `tunnel` - return new Promise((resolve, reject) => { - let tunnelProcess: ChildProcess; - const stdio: StdioOptions = ['ignore', 'pipe', 'pipe']; - if (process.env['VSCODE_DEV']) { - tunnelProcess = spawn('cargo', ['run', '--', subcommand, ...tunnelArgs], { cwd: join(getAppRoot(), 'cli'), stdio }); - } else { - const appPath = process.platform === 'darwin' - // ./Contents/MacOS/Electron => ./Contents/Resources/app/bin/code-tunnel-insiders - ? join(dirname(dirname(process.execPath)), 'Resources', 'app') - : dirname(process.execPath); - const tunnelCommand = join(appPath, 'bin', `${product.tunnelApplicationName}${isWindows ? '.exe' : ''}`); - tunnelProcess = spawn(tunnelCommand, [subcommand, ...tunnelArgs], { cwd: cwd(), stdio }); - } + // for (const subcommand of NATIVE_CLI_COMMANDS) { + // if (args[subcommand]) { + // if (!product.tunnelApplicationName) { + // console.error(`'${subcommand}' command not supported in ${product.applicationName}`); + // return; + // } + // const tunnelArgs = argv.slice(argv.indexOf(subcommand) + 1); // all arguments behind `tunnel` + // return new Promise((resolve, reject) => { + // let tunnelProcess: ChildProcess; + // const stdio: StdioOptions = ['ignore', 'pipe', 'pipe']; + // if (process.env['VSCODE_DEV']) { + // tunnelProcess = spawn('cargo', ['run', '--', subcommand, ...tunnelArgs], { cwd: join(getAppRoot(), 'cli'), stdio }); + // } else { + // const appPath = process.platform === 'darwin' + // // ./Contents/MacOS/Electron => ./Contents/Resources/app/bin/code-tunnel-insiders + // ? join(dirname(dirname(process.execPath)), 'Resources', 'app') + // : dirname(process.execPath); + // const tunnelCommand = join(appPath, 'bin', `${product.tunnelApplicationName}${isWindows ? '.exe' : ''}`); + // tunnelProcess = spawn(tunnelCommand, [subcommand, ...tunnelArgs], { cwd: cwd(), stdio }); + // } - tunnelProcess.stdout!.pipe(process.stdout); - tunnelProcess.stderr!.pipe(process.stderr); - tunnelProcess.on('exit', resolve); - tunnelProcess.on('error', reject); - }); - } - } + // tunnelProcess.stdout!.pipe(process.stdout); + // tunnelProcess.stderr!.pipe(process.stderr); + // tunnelProcess.on('exit', resolve); + // tunnelProcess.on('error', reject); + // }); + // } + // } // Help if (args.help) { diff --git a/src/vs/platform/environment/common/argv.ts b/src/vs/platform/environment/common/argv.ts index f205cc30..e7f6c02d 100644 --- a/src/vs/platform/environment/common/argv.ts +++ b/src/vs/platform/environment/common/argv.ts @@ -14,15 +14,15 @@ export interface INativeCliOptions { */ export interface NativeParsedArgs { // subcommands - tunnel?: INativeCliOptions & { - user: { - login: { - 'access-token'?: string; - 'provider'?: string; - }; - }; - }; - 'serve-web'?: INativeCliOptions; + // tunnel?: INativeCliOptions & { + // user: { + // login: { + // 'access-token'?: string; + // 'provider'?: string; + // }; + // }; + // }; + // 'serve-web'?: INativeCliOptions; _: string[]; 'folder-uri'?: string[]; // undefined or array of 1 or more 'file-uri'?: string[]; // undefined or array of 1 or more diff --git a/src/vs/platform/environment/node/argv.ts b/src/vs/platform/environment/node/argv.ts index 79046c7f..eb635f9b 100644 --- a/src/vs/platform/environment/node/argv.ts +++ b/src/vs/platform/environment/node/argv.ts @@ -47,36 +47,36 @@ export type OptionDescriptions = { export const NATIVE_CLI_COMMANDS = ['tunnel', 'serve-web'] as const; export const OPTIONS: OptionDescriptions> = { - 'tunnel': { - type: 'subcommand', - description: 'Make the current machine accessible from vscode.dev or other machines through a secure tunnel', - options: { - 'cli-data-dir': { type: 'string', args: 'dir', description: localize('cliDataDir', "Directory where CLI metadata should be stored.") }, - 'disable-telemetry': { type: 'boolean' }, - 'telemetry-level': { type: 'string' }, - user: { - type: 'subcommand', - options: { - login: { - type: 'subcommand', - options: { - provider: { type: 'string' }, - 'access-token': { type: 'string' } - } - } - } - } - } - }, - 'serve-web': { - type: 'subcommand', - description: 'Run a server that displays the editor UI in browsers.', - options: { - 'cli-data-dir': { type: 'string', args: 'dir', description: localize('cliDataDir', "Directory where CLI metadata should be stored.") }, - 'disable-telemetry': { type: 'boolean' }, - 'telemetry-level': { type: 'string' }, - } - }, + // 'tunnel': { + // type: 'subcommand', + // description: 'Make the current machine accessible from vscode.dev or other machines through a secure tunnel', + // options: { + // 'cli-data-dir': { type: 'string', args: 'dir', description: localize('cliDataDir', "Directory where CLI metadata should be stored.") }, + // 'disable-telemetry': { type: 'boolean' }, + // 'telemetry-level': { type: 'string' }, + // user: { + // type: 'subcommand', + // options: { + // login: { + // type: 'subcommand', + // options: { + // provider: { type: 'string' }, + // 'access-token': { type: 'string' } + // } + // } + // } + // } + // } + // }, + // 'serve-web': { + // type: 'subcommand', + // description: 'Run a server that displays the editor UI in browsers.', + // options: { + // 'cli-data-dir': { type: 'string', args: 'dir', description: localize('cliDataDir', "Directory where CLI metadata should be stored.") }, + // 'disable-telemetry': { type: 'boolean' }, + // 'telemetry-level': { type: 'string' }, + // } + // }, 'diff': { type: 'boolean', cat: 'o', alias: 'd', args: ['file', 'file'], description: localize('diff', "Compare two files with each other.") }, 'merge': { type: 'boolean', cat: 'o', alias: 'm', args: ['path1', 'path2', 'base', 'result'], description: localize('merge', "Perform a three-way merge by providing paths for two modified versions of a file, the common origin of both modified versions and the output file to save merge results.") },