mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
Merge remote-tracking branch 'origin/main' into alex/issue-140997
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
title VSCode Remote Agent
|
||||
|
||||
pushd %~dp0\..\..\..
|
||||
|
||||
:: Configuration
|
||||
set NODE_ENV=development
|
||||
set VSCODE_DEV=1
|
||||
|
||||
:: Sync built-in extensions
|
||||
call yarn download-builtin-extensions
|
||||
|
||||
FOR /F "tokens=*" %%g IN ('node build/lib/node.js') do (SET NODE=%%g)
|
||||
|
||||
:: Download nodejs executable for remote
|
||||
IF NOT EXIST "%NODE%" (
|
||||
call yarn gulp node
|
||||
)
|
||||
|
||||
:: Launch Agent
|
||||
set _FIRST_ARG=%1
|
||||
if "%_FIRST_ARG:~0,9%"=="--inspect" (
|
||||
set INSPECT=%1
|
||||
shift
|
||||
) else (
|
||||
set INSPECT=
|
||||
)
|
||||
|
||||
:loop1
|
||||
if "%~1"=="" goto after_loop
|
||||
set RESTVAR=%RESTVAR% %1
|
||||
shift
|
||||
goto loop1
|
||||
|
||||
:after_loop
|
||||
|
||||
call "%NODE%" %INSPECT% "out\server-main.js" %RESTVAR%
|
||||
|
||||
popd
|
||||
|
||||
endlocal
|
||||
93
resources/server/bin-dev/code-server.js
Normal file
93
resources/server/bin-dev/code-server.js
Normal file
@@ -0,0 +1,93 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// @ts-check
|
||||
|
||||
const cp = require('child_process');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const opn = require('opn');
|
||||
const crypto = require('crypto');
|
||||
const minimist = require('minimist');
|
||||
|
||||
const args = minimist(process.argv.slice(2), {
|
||||
boolean: [
|
||||
'help',
|
||||
],
|
||||
string: [
|
||||
'host',
|
||||
'port',
|
||||
'driver',
|
||||
'connection-token'
|
||||
],
|
||||
});
|
||||
|
||||
if (args.help) {
|
||||
console.log(
|
||||
'./scripts/code-server.sh|bat [options]\n' +
|
||||
' --launch Opens a browser'
|
||||
);
|
||||
}
|
||||
|
||||
const serverArgs = process.argv.slice(2).filter(v => v !== '--launch');
|
||||
|
||||
const HOST = args['host'] ?? 'localhost';
|
||||
const PORT = args['port'] ?? '9888';
|
||||
const TOKEN = args['connection-token'] ?? String(crypto.randomInt(0xffffffff));
|
||||
|
||||
if (!args['connection-token'] === undefined && !args['connection-token-file'] === undefined && !args['no-connection-token']) {
|
||||
serverArgs.push('--connection-token', TOKEN);
|
||||
}
|
||||
if (args['host'] === undefined) {
|
||||
serverArgs.push('--host', HOST);
|
||||
}
|
||||
if (args['port'] === undefined) {
|
||||
serverArgs.push('--port', PORT);
|
||||
}
|
||||
|
||||
if (args['driver']) {
|
||||
// given a DRIVER, we auto-shutdown when tests are done
|
||||
serverArgs.push('--enable-remote-auto-shutdown', '--remote-auto-shutdown-without-delay');
|
||||
}
|
||||
|
||||
const env = { ...process.env };
|
||||
env['VSCODE_AGENT_FOLDER'] = env['VSCODE_AGENT_FOLDER'] || path.join(os.homedir(), '.vscode-server-oss-dev');
|
||||
env['NODE_ENV'] = 'development';
|
||||
env['VSCODE_DEV'] = '1';
|
||||
const entryPoint = path.join(__dirname, '..', '..', '..', 'out', 'server-main.js');
|
||||
|
||||
startServer();
|
||||
|
||||
function startServer() {
|
||||
console.log(`Starting server: ${entryPoint} ${serverArgs.join(' ')}`);
|
||||
const proc = cp.spawn(process.execPath, [entryPoint, ...serverArgs], { env });
|
||||
|
||||
proc.stdout.on('data', data => {
|
||||
// Log everything
|
||||
console.log(data.toString());
|
||||
});
|
||||
|
||||
// Log errors
|
||||
proc.stderr.on('data', data => {
|
||||
console.error(data.toString());
|
||||
});
|
||||
|
||||
proc.on('exit', () => process.exit());
|
||||
|
||||
process.on('exit', () => proc.kill());
|
||||
process.on('SIGINT', () => {
|
||||
proc.kill();
|
||||
process.exit(128 + 2); // https://nodejs.org/docs/v14.16.0/api/process.html#process_signal_events
|
||||
});
|
||||
process.on('SIGTERM', () => {
|
||||
proc.kill();
|
||||
process.exit(128 + 15); // https://nodejs.org/docs/v14.16.0/api/process.html#process_signal_events
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (args['launch']) {
|
||||
opn(`http://${HOST}:${PORT}/?tkn=${TOKEN}`);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
realpath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"; }
|
||||
ROOT=$(dirname $(dirname $(dirname $(dirname $(realpath "$0")))))
|
||||
else
|
||||
ROOT=$(dirname $(dirname $(dirname $(dirname $(readlink -f $0)))))
|
||||
fi
|
||||
|
||||
function code() {
|
||||
cd $ROOT
|
||||
|
||||
# Sync built-in extensions
|
||||
yarn download-builtin-extensions
|
||||
|
||||
NODE=$(node build/lib/node.js)
|
||||
|
||||
# Download nodejs
|
||||
if [ ! -f $NODE ]; then
|
||||
yarn gulp node
|
||||
fi
|
||||
|
||||
NODE_ENV=development \
|
||||
VSCODE_DEV=1 \
|
||||
$NODE "$ROOT/out/server-main.js" "$@"
|
||||
}
|
||||
|
||||
code "$@"
|
||||
@@ -1,87 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// @ts-check
|
||||
|
||||
const cp = require('child_process');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
|
||||
const serverArgs = [];
|
||||
|
||||
// Server Config
|
||||
let PORT = 9888;
|
||||
let DRIVER = undefined;
|
||||
let LOGS_PATH = undefined;
|
||||
|
||||
// Workspace Config
|
||||
let FOLDER = undefined;
|
||||
let WORKSPACE = undefined;
|
||||
|
||||
// Settings Sync Config
|
||||
let GITHUB_AUTH_TOKEN = undefined;
|
||||
let ENABLE_SYNC = false;
|
||||
|
||||
for (let idx = 0; idx <= process.argv.length - 2; idx++) {
|
||||
const arg = process.argv[idx];
|
||||
switch (arg) {
|
||||
case '--port': PORT = Number(process.argv[idx + 1]); break;
|
||||
case '--folder': FOLDER = process.argv[idx + 1]; break;
|
||||
case '--workspace': WORKSPACE = process.argv[idx + 1]; break;
|
||||
case '--driver': DRIVER = process.argv[idx + 1]; break;
|
||||
case '--github-auth': GITHUB_AUTH_TOKEN = process.argv[idx + 1]; break;
|
||||
case '--logsPath': LOGS_PATH = process.argv[idx + 1]; break;
|
||||
case '--enable-sync': ENABLE_SYNC = true; break;
|
||||
}
|
||||
}
|
||||
|
||||
serverArgs.push('--port', String(PORT));
|
||||
if (FOLDER) {
|
||||
serverArgs.push('--folder', FOLDER);
|
||||
}
|
||||
if (WORKSPACE) {
|
||||
serverArgs.push('--workspace', WORKSPACE);
|
||||
}
|
||||
if (DRIVER) {
|
||||
serverArgs.push('--driver', DRIVER);
|
||||
|
||||
// given a DRIVER, we auto-shutdown when tests are done
|
||||
serverArgs.push('--enable-remote-auto-shutdown', '--remote-auto-shutdown-without-delay');
|
||||
}
|
||||
if (LOGS_PATH) {
|
||||
serverArgs.push('--logsPath', LOGS_PATH);
|
||||
}
|
||||
if (GITHUB_AUTH_TOKEN) {
|
||||
serverArgs.push('--github-auth', GITHUB_AUTH_TOKEN);
|
||||
}
|
||||
if (ENABLE_SYNC) {
|
||||
serverArgs.push('--enable-sync', true);
|
||||
}
|
||||
|
||||
// Connection Token
|
||||
serverArgs.push('--connection-token', '00000');
|
||||
|
||||
// Server should really only listen from localhost
|
||||
serverArgs.push('--host', '127.0.0.1');
|
||||
|
||||
const env = { ...process.env };
|
||||
env['VSCODE_AGENT_FOLDER'] = env['VSCODE_AGENT_FOLDER'] || path.join(os.homedir(), '.vscode-web-dev');
|
||||
const entryPoint = path.join(__dirname, '..', '..', '..', 'out', 'vs', 'server', 'main.js');
|
||||
|
||||
startServer();
|
||||
|
||||
function startServer() {
|
||||
const proc = cp.spawn(process.execPath, [entryPoint, ...serverArgs], { env });
|
||||
|
||||
proc.stdout.on('data', data => {
|
||||
// Log everything
|
||||
console.log(data.toString());
|
||||
});
|
||||
|
||||
// Log errors
|
||||
proc.stderr.on('data', data => {
|
||||
console.error(data.toString());
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user