server bin cleanup

This commit is contained in:
Martin Aeschlimann
2022-01-11 16:34:28 +01:00
parent 1942718a4a
commit f4ba7dd12b
18 changed files with 78 additions and 26 deletions

View File

@@ -300,26 +300,28 @@ function packageTask(type, platform, arch, sourceFolderName, destinationFolderNa
if (platform === 'win32') {
result = es.merge(result,
gulp.src('resources/server/bin/code.cmd', { base: '.' })
gulp.src('resources/server/bin/remote-cli/code.cmd', { base: '.' })
.pipe(replace('@@VERSION@@', version))
.pipe(replace('@@COMMIT@@', commit))
.pipe(replace('@@APPNAME@@', product.applicationName))
.pipe(rename(`bin/${product.applicationName}.cmd`)),
.pipe(rename(`bin/remote-cli/${product.applicationName}.cmd`)),
gulp.src('resources/server/bin/helpers/browser.cmd', { base: '.' })
.pipe(replace('@@VERSION@@', version))
.pipe(replace('@@COMMIT@@', commit))
.pipe(replace('@@APPNAME@@', product.applicationName))
.pipe(rename(`bin/helpers/browser.cmd`)),
gulp.src('resources/server/bin/server.cmd', { base: '.' })
.pipe(rename(`server.cmd`))
gulp.src('resources/server/bin/server-old.cmd', { base: '.' })
.pipe(rename(`server.cmd`)),
gulp.src('resources/server/bin/code-server.cmd', { base: '.' })
.pipe(rename(`bin/${product.serverApplicationName}.cmd`)),
);
} else if (platform === 'linux' || platform === 'alpine' || platform === 'darwin') {
result = es.merge(result,
gulp.src('resources/server/bin/code.sh', { base: '.' })
gulp.src('resources/server/bin/remote-cli/code.sh', { base: '.' })
.pipe(replace('@@VERSION@@', version))
.pipe(replace('@@COMMIT@@', commit))
.pipe(replace('@@APPNAME@@', product.applicationName))
.pipe(rename(`bin/${product.applicationName}`))
.pipe(rename(`bin/remote-cli/${product.applicationName}`))
.pipe(util.setExecutableBit()),
gulp.src('resources/server/bin/helpers/browser.sh', { base: '.' })
.pipe(replace('@@VERSION@@', version))
@@ -327,8 +329,11 @@ function packageTask(type, platform, arch, sourceFolderName, destinationFolderNa
.pipe(replace('@@APPNAME@@', product.applicationName))
.pipe(rename(`bin/helpers/browser.sh`))
.pipe(util.setExecutableBit()),
gulp.src('resources/server/bin/server.sh', { base: '.' })
gulp.src('resources/server/bin/server-old.sh', { base: '.' })
.pipe(rename(`server.sh`))
.pipe(util.setExecutableBit()),
gulp.src('resources/server/bin/code-server.sh', { base: '.' })
.pipe(rename(`bin/${product.serverApplicationName}`))
.pipe(util.setExecutableBit())
);
}

View File

@@ -82,7 +82,7 @@ export function activate(context: vscode.ExtensionContext) {
return;
}
const { updateUrl, commit, quality, serverDataFolderName, dataFolderName } = getProductConfiguration();
const { updateUrl, commit, quality, serverDataFolderName, serverApplicationName, dataFolderName } = getProductConfiguration();
const commandArgs = ['--host=127.0.0.1', '--port=0', '--disable-telemetry', '--use-host-proxy', '--accept-server-license-terms'];
const env = getNewEnv();
const remoteDataDir = process.env['TESTRESOLVER_DATA_FOLDER'] || path.join(os.homedir(), serverDataFolderName || `${dataFolderName}-testresolver`);
@@ -102,7 +102,7 @@ export function activate(context: vscode.ExtensionContext) {
commandArgs.push('--connection-token-file', connectionTokenFile);
if (!commit) { // dev mode
const serverCommand = process.platform === 'win32' ? 'server.bat' : 'server.sh';
const serverCommand = process.platform === 'win32' ? 'code-server.bat' : 'code-server.sh';
const vscodePath = path.resolve(path.join(context.extensionPath, '..', '..'));
const serverCommandPath = path.join(vscodePath, 'resources', 'server', 'bin-dev', serverCommand);
@@ -115,7 +115,7 @@ export function activate(context: vscode.ExtensionContext) {
commandArgs.push('--install-builtin-extension', extensionToInstall);
commandArgs.push('--start-server');
}
const serverCommand = process.platform === 'win32' ? 'server.cmd' : 'server.sh';
const serverCommand = `${serverApplicationName}${process.platform === 'win32' ? '.cmd' : ''}`;
let serverLocation = env['VSCODE_REMOTE_SERVER_PATH']; // support environment variable to specify location of server on disk
if (!serverLocation) {
const serverBin = path.join(remoteDataDir, 'bin');
@@ -390,6 +390,7 @@ export interface IProductConfiguration {
commit: string;
quality: string;
dataFolderName: string;
serverApplicationName?: string;
serverDataFolderName?: string;
}

View File

@@ -9,6 +9,7 @@
"serverGreeting": [],
"serverLicense": [],
"serverLicensePrompt": "",
"serverApplicationName": "code-server-oss",
"win32DirName": "Microsoft Code OSS",
"win32NameVersion": "Microsoft Code OSS",
"win32RegValueName": "CodeOSS",

View File

@@ -1,6 +1,6 @@
@echo off
setlocal
SET VSCODE_PATH=%~dp0..\..\..
SET VSCODE_PATH=%~dp0..\..\..\..
FOR /F "tokens=* USEBACKQ" %%g IN (`where /r "%VSCODE_PATH%\.build\node" node.exe`) do (SET "NODE=%%g")
call "%NODE%" "%VSCODE_PATH%\out\vs\server\cli.js" "Code Server - Dev" "" "" "code.cmd" %*
endlocal

View File

@@ -5,9 +5,9 @@
if [[ "$OSTYPE" == "darwin"* ]]; then
realpath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"; }
VSCODE_PATH=$(dirname $(dirname $(dirname $(dirname $(realpath "$0")))))
VSCODE_PATH=$(dirname $(dirname $(dirname $(dirname $(dirname $(realpath "$0"))))))
else
VSCODE_PATH=$(dirname $(dirname $(dirname $(dirname $(readlink -f $0)))))
VSCODE_PATH=$(dirname $(dirname $(dirname $(dirname $(dirname $(readlink -f $0))))))
fi
PROD_NAME="Code Server - Dev"

View File

@@ -0,0 +1,24 @@
@echo off
setlocal
set ROOT_DIR=%~dp0..
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
"%ROOT_DIR%\node.exe" %INSPECT% "%ROOT_DIR%\out\vs\server\main.js" %RESTVAR%
endlocal

View File

@@ -7,6 +7,6 @@ case "$1" in
--inspect*) INSPECT="$1"; shift;;
esac
ROOT="$(dirname "$0")"
ROOT=$(dirname "$(dirname "$0")")
"$ROOT/node" ${INSPECT:-} "$ROOT/out/vs/server/main.js" "$@"

View File

@@ -1,4 +0,0 @@
@echo off
setlocal
call "%~dp0..\node" "%~dp0..\out\vs\server\cli.js" "@@APPNAME@@" "@@VERSION@@" "@@COMMIT@@" "@@APPNAME@@.cmd" %*
endlocal

View File

@@ -1,4 +1,5 @@
@echo off
setlocal
call "%~dp0..\..\node" "%~dp0..\..\out\vs\server\cli.js" "@@APPNAME@@" "@@VERSION@@" "@@COMMIT@@" "@@APPNAME@@.cmd" "--openExternal" %*
set ROOT_DIR=%~dp0..\..
call "%ROOT_DIR%\node.exe" "%ROOT_DIR%\out\vs\server\cli.js" "@@APPNAME@@" "@@VERSION@@" "@@COMMIT@@" "@@APPNAME@@.cmd" "--openExternal" %*
endlocal

View File

@@ -0,0 +1,5 @@
@echo off
setlocal
set ROOT_DIR=%~dp0..\..
call "%ROOT_DIR%\node.exe" "%ROOT_DIR%\out\vs\server\cli.js" "@@APPNAME@@" "@@VERSION@@" "@@COMMIT@@" "@@APPNAME@@.cmd" %*
endlocal

View File

@@ -2,7 +2,7 @@
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
ROOT=$(dirname "$(dirname "$0")")
ROOT=$(dirname "$(dirname "$(dirname "$0")")")
APP_NAME="@@APPNAME@@"
VERSION="@@VERSION@@"

View File

@@ -19,6 +19,6 @@ goto loop1
:after_loop
"%ROOT_DIR%node.exe" %INSPECT% "%ROOT_DIR%out\vs\server\main.js" %RESTVAR%
"%ROOT_DIR%node.exe" %INSPECT% "%ROOT_DIR%out\vs\server\main.js" --compatibility=1.63 %RESTVAR%
endlocal

View File

@@ -0,0 +1,12 @@
#!/usr/bin/env sh
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
case "$1" in
--inspect*) INSPECT="$1"; shift;;
esac
ROOT="$(dirname "$0")"
"$ROOT/node" ${INSPECT:-} "$ROOT/out/vs/server/main.js" --compatibility=1.63 "$@"

View File

@@ -34,12 +34,13 @@ export async function buildUserEnvironment(startParamsEnv: { [key: string]: stri
}
const binFolder = environmentService.isBuilt ? join(environmentService.appRoot, 'bin') : join(environmentService.appRoot, 'resources', 'server', 'bin-dev');
const remoteCliBinFolder = join(binFolder, 'remote-cli'); // contains the `code` command that can talk to the remote server
const processEnv = process.env;
let PATH = startParamsEnv['PATH'] || (userShellEnv ? userShellEnv['PATH'] : undefined) || processEnv['PATH'];
if (PATH) {
PATH = binFolder + delimiter + PATH;
PATH = remoteCliBinFolder + delimiter + PATH;
} else {
PATH = binFolder;
PATH = remoteCliBinFolder;
}
const env: IProcessEnvironment = {
@@ -58,7 +59,7 @@ export async function buildUserEnvironment(startParamsEnv: { [key: string]: stri
...startParamsEnv
};
if (!environmentService.args['without-browser-env-var']) {
env.BROWSER = join(binFolder, 'helpers', isWindows ? 'browser.cmd' : 'browser.sh');
env.BROWSER = join(binFolder, 'helpers', isWindows ? 'browser.cmd' : 'browser.sh'); // a command that opens a browser on the local machine
}
setCaseInsensitive(env, 'PATH', PATH);

View File

@@ -925,6 +925,7 @@ function parseConnectionToken(args: ServerParsedArgs): { connectionToken: string
let connectionToken = args['connection-token'];
const connectionTokenFile = args['connection-token-file'];
const compatibility = args['compatibility'] === '1.63';
if (args['without-connection-token']) {
if (connectionToken || connectionTokenFile) {
@@ -959,9 +960,11 @@ function parseConnectionToken(args: ServerParsedArgs): { connectionToken: string
} else {
connectionToken = generateUuid();
console.log(`Connection token: ${connectionToken}`);
console.log(`Connection token or will made mandatory in the next release. To run without connection token, use '--without-connection-token'.`);
if (compatibility) {
console.log(`Connection token or will made mandatory in the next release. To run without connection token, use '--without-connection-token'.`);
}
}
return { connectionToken, connectionTokenIsMandatory: false };
return { connectionToken, connectionTokenIsMandatory: !compatibility };
}
}

View File

@@ -76,6 +76,7 @@ export const serverOptions: OptionDescriptions<ServerParsedArgs> = {
'help': OPTIONS['help'],
'version': OPTIONS['version'],
'compatibility': { type: 'string' },
_: OPTIONS['_']
};
@@ -175,6 +176,8 @@ export interface ServerParsedArgs {
help: boolean;
version: boolean;
compatibility: string
_: string[];
}