Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Aeschlimann <martinae@microsoft.com>2022-01-21 16:33:34 +0300
committerMartin Aeschlimann <martinae@microsoft.com>2022-01-21 16:33:34 +0300
commit3640c1a425713e905f7898917cd15cc077204697 (patch)
tree2c4dd5cee4cd6f34901430cc608eb7b9a8f255ea /resources
parent0d8bb5f2baadc73f6231cf73030fe819d251ef21 (diff)
move remote and web tests to scripts folder
Diffstat (limited to 'resources')
-rw-r--r--resources/server/bin-dev/code-server.js89
-rw-r--r--resources/server/test/test-remote-integration.bat80
-rwxr-xr-xresources/server/test/test-remote-integration.sh115
-rw-r--r--resources/server/test/test-web-integration.bat55
-rwxr-xr-xresources/server/test/test-web-integration.sh36
-rw-r--r--resources/web/bin-dev/code-web-playground.js130
6 files changed, 0 insertions, 505 deletions
diff --git a/resources/server/bin-dev/code-server.js b/resources/server/bin-dev/code-server.js
deleted file mode 100644
index 26b93a03465..00000000000
--- a/resources/server/bin-dev/code-server.js
+++ /dev/null
@@ -1,89 +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 opn = require('opn');
-const crypto = require('crypto');
-const minimist = require('minimist');
-
-const args = minimist(process.argv.slice(2), {
- boolean: [
- 'help',
- 'launch'
- ],
- string: [
- 'host',
- 'port',
- 'driver',
- 'connection-token',
- 'server-data-dir'
- ],
-});
-
-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['launch'] && 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);
-}
-
-const env = { ...process.env };
-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', (code) => process.exit(code));
-
- 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}`);
-}
diff --git a/resources/server/test/test-remote-integration.bat b/resources/server/test/test-remote-integration.bat
deleted file mode 100644
index c31dff424d2..00000000000
--- a/resources/server/test/test-remote-integration.bat
+++ /dev/null
@@ -1,80 +0,0 @@
-@echo off
-setlocal
-
-pushd %~dp0\..\..\..
-
-IF "%~1" == "" (
- set AUTHORITY=vscode-remote://test+test/
- :: backward to forward slashed
- set EXT_PATH=%CD:\=/%/extensions
-
- :: Download nodejs executable for remote
- call yarn gulp node
-) else (
- set AUTHORITY=%1
- set EXT_PATH=%2
- set VSCODEUSERDATADIR=%3
-)
-IF "%VSCODEUSERDATADIR%" == "" (
- set VSCODEUSERDATADIR=%TMP%\vscodeuserfolder-%RANDOM%-%TIME:~6,5%
-)
-
-set REMOTE_VSCODE=%AUTHORITY%%EXT_PATH%
-set VSCODECRASHDIR=%~dp0\..\..\..\.build\crashes
-set VSCODELOGSDIR=%~dp0\..\..\..\.build\logs\integration-tests-remote
-set TESTRESOLVER_DATA_FOLDER=%TMP%\testresolverdatafolder-%RANDOM%-%TIME:~6,5%
-set TESTRESOLVER_LOGS_FOLDER=%VSCODELOGSDIR%\server
-
-if "%VSCODE_REMOTE_SERVER_PATH%"=="" (
- echo "Using remote server out of sources for integration tests"
-) else (
- set TESTRESOLVER_INSTALL_BUILTIN_EXTENSION=ms-vscode.vscode-smoketest-check
- echo "Using %VSCODE_REMOTE_SERVER_PATH% as server path"
-)
-
-set API_TESTS_EXTRA_ARGS=--disable-telemetry --skip-welcome --skip-release-notes --crash-reporter-directory=%VSCODECRASHDIR% --logsPath=%VSCODELOGSDIR% --no-cached-data --disable-updates --disable-keytar --disable-inspect --disable-workspace-trust --user-data-dir=%VSCODEUSERDATADIR%
-
-:: Figure out which Electron to use for running tests
-if "%INTEGRATION_TEST_ELECTRON_PATH%"=="" (
- echo "Storing crash reports into '%VSCODECRASHDIR%'."
- echo "Storing log files into '%VSCODELOGSDIR%'."
-
- :: Tests in the extension host running from sources
- call .\scripts\code.bat --folder-uri=%REMOTE_VSCODE%/vscode-api-tests/testWorkspace --extensionDevelopmentPath=%REMOTE_VSCODE%/vscode-api-tests --extensionTestsPath=%REMOTE_VSCODE%/vscode-api-tests/out/singlefolder-tests %API_TESTS_EXTRA_ARGS%
- if %errorlevel% neq 0 exit /b %errorlevel%
-
- call .\scripts\code.bat --file-uri=%REMOTE_VSCODE%/vscode-api-tests/testworkspace.code-workspace --extensionDevelopmentPath=%REMOTE_VSCODE%/vscode-api-tests --extensionTestsPath=%REMOTE_VSCODE%/vscode-api-tests/out/workspace-tests %API_TESTS_EXTRA_ARGS%
- if %errorlevel% neq 0 exit /b %errorlevel%
-) else (
- echo "Storing crash reports into '%VSCODECRASHDIR%'."
- echo "Storing log files into '%VSCODELOGSDIR%'."
- echo "Using %INTEGRATION_TEST_ELECTRON_PATH% as Electron path"
-
- :: Run from a built: need to compile all test extensions
- :: because we run extension tests from their source folders
- :: and the build bundles extensions into .build webpacked
- call yarn gulp compile-extension:vscode-api-tests^
- compile-extension:vscode-test-resolver
-
- :: Configuration for more verbose output
- set VSCODE_CLI=1
- set ELECTRON_ENABLE_LOGGING=1
- set ELECTRON_ENABLE_STACK_DUMPING=1
-
- :: Tests in the extension host running from built version (both client and server)
- call "%INTEGRATION_TEST_ELECTRON_PATH%" --folder-uri=%REMOTE_VSCODE%/vscode-api-tests/testWorkspace --extensionDevelopmentPath=%REMOTE_VSCODE%/vscode-api-tests --extensionTestsPath=%REMOTE_VSCODE%/vscode-api-tests/out/singlefolder-tests %API_TESTS_EXTRA_ARGS% --extensions-dir=%EXT_PATH% --enable-proposed-api=vscode.vscode-test-resolver --enable-proposed-api=vscode.vscode-api-tests --enable-proposed-api=vscode.image-preview
- if %errorlevel% neq 0 exit /b %errorlevel%
-
- call "%INTEGRATION_TEST_ELECTRON_PATH%" --file-uri=%REMOTE_VSCODE%/vscode-api-tests/testworkspace.code-workspace --extensionDevelopmentPath=%REMOTE_VSCODE%/vscode-api-tests --extensionTestsPath=%REMOTE_VSCODE%/vscode-api-tests/out/workspace-tests %API_TESTS_EXTRA_ARGS% --extensions-dir=%EXT_PATH% --enable-proposed-api=vscode.vscode-test-resolver --enable-proposed-api=vscode.vscode-api-tests --enable-proposed-api=vscode.image-preview
- if %errorlevel% neq 0 exit /b %errorlevel%
-)
-
-IF "%3" == "" (
- rmdir /s /q %VSCODEUSERDATADIR%
-)
-
-rmdir /s /q %TESTRESOLVER_DATA_FOLDER%
-
-popd
-
-endlocal
diff --git a/resources/server/test/test-remote-integration.sh b/resources/server/test/test-remote-integration.sh
deleted file mode 100755
index 71fee7327b4..00000000000
--- a/resources/server/test/test-remote-integration.sh
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/bin/bash
-set -e
-
-if [[ "$OSTYPE" == "darwin"* ]]; then
- realpath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"; }
- ROOT=$(dirname $(dirname $(dirname $(dirname $(realpath "$0")))))
- VSCODEUSERDATADIR=`mktemp -d -t 'myuserdatadir'`
- TESTRESOLVER_DATA_FOLDER=`mktemp -d -t 'testresolverdatafolder'`
-else
- ROOT=$(dirname $(dirname $(dirname $(dirname $(readlink -f $0)))))
- VSCODEUSERDATADIR=`mktemp -d 2>/dev/null`
- TESTRESOLVER_DATA_FOLDER=`mktemp -d 2>/dev/null`
- # --disable-dev-shm-usage --use-gl=swiftshader: when run on docker containers where size of /dev/shm
- # partition < 64MB which causes OOM failure for chromium compositor that uses the partition for shared memory
- LINUX_EXTRA_ARGS="--disable-dev-shm-usage --use-gl=swiftshader"
-fi
-
-cd $ROOT
-if [[ "$1" == "" ]]; then
- AUTHORITY=vscode-remote://test+test
- EXT_PATH=$ROOT/extensions
- # Load remote node
- yarn gulp node
-else
- AUTHORITY=$1
- EXT_PATH=$2
- VSCODEUSERDATADIR=${3:-$VSCODEUSERDATADIR}
-fi
-
-export REMOTE_VSCODE=$AUTHORITY$EXT_PATH
-VSCODECRASHDIR=$ROOT/.build/crashes
-VSCODELOGSDIR=$ROOT/.build/logs/integration-tests-remote
-
-# Figure out which Electron to use for running tests
-if [ -z "$INTEGRATION_TEST_ELECTRON_PATH" ]
-then
- echo "Storing crash reports into '$VSCODECRASHDIR'."
- echo "Storing log files into '$VSCODELOGSDIR'."
-
- # code.sh makes sure Test Extensions are compiled
- INTEGRATION_TEST_ELECTRON_PATH="./scripts/code.sh"
-
- # No extra arguments when running out of sources
- EXTRA_INTEGRATION_TEST_ARGUMENTS=""
-else
- echo "Storing crash reports into '$VSCODECRASHDIR'."
- echo "Storing log files into '$VSCODELOGSDIR'."
- echo "Using $INTEGRATION_TEST_ELECTRON_PATH as Electron path for integration tests"
-
- # Run from a built: need to compile all test extensions
- # because we run extension tests from their source folders
- # and the build bundles extensions into .build webpacked
- yarn gulp compile-extension:vscode-api-tests \
- compile-extension:vscode-test-resolver \
- compile-extension:markdown-language-features \
- compile-extension:typescript-language-features \
- compile-extension:emmet \
- compile-extension:git \
- compile-extension-media
-
- # Configuration for more verbose output
- export VSCODE_CLI=1
- export ELECTRON_ENABLE_STACK_DUMPING=1
- export ELECTRON_ENABLE_LOGGING=1
-
- # Running from a build, we need to enable the vscode-test-resolver extension
- EXTRA_INTEGRATION_TEST_ARGUMENTS="--extensions-dir=$EXT_PATH --enable-proposed-api=vscode.vscode-test-resolver --enable-proposed-api=vscode.vscode-api-tests --enable-proposed-api=vscode.image-preview --enable-proposed-api=vscode.git"
-fi
-
-if [ -z "$INTEGRATION_TEST_APP_NAME" ]; then
- after_suite() { true; }
-else
- after_suite() { killall $INTEGRATION_TEST_APP_NAME || true; }
-fi
-
-export TESTRESOLVER_DATA_FOLDER=$TESTRESOLVER_DATA_FOLDER
-export TESTRESOLVER_LOGS_FOLDER=$VSCODELOGSDIR/server
-
-# Figure out which remote server to use for running tests
-if [ -z "$VSCODE_REMOTE_SERVER_PATH" ]
-then
- echo "Using remote server out of sources for integration tests"
-else
- echo "Using $VSCODE_REMOTE_SERVER_PATH as server path for integration tests"
- export TESTRESOLVER_INSTALL_BUILTIN_EXTENSION='ms-vscode.vscode-smoketest-check'
-fi
-
-# Tests in the extension host
-
-API_TESTS_DEFAULT_EXTRA_ARGS="--disable-telemetry --skip-welcome --skip-release-notes --crash-reporter-directory=$VSCODECRASHDIR --logsPath=$VSCODELOGSDIR --no-cached-data --disable-updates --disable-keytar --disable-inspect --disable-workspace-trust --user-data-dir=$VSCODEUSERDATADIR"
-
-"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS --folder-uri=$REMOTE_VSCODE/vscode-api-tests/testWorkspace --extensionDevelopmentPath=$REMOTE_VSCODE/vscode-api-tests --extensionTestsPath=$REMOTE_VSCODE/vscode-api-tests/out/singlefolder-tests $API_TESTS_DEFAULT_EXTRA_ARGS $EXTRA_INTEGRATION_TEST_ARGUMENTS
-after_suite
-
-"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS --file-uri=$REMOTE_VSCODE/vscode-api-tests/testworkspace.code-workspace --extensionDevelopmentPath=$REMOTE_VSCODE/vscode-api-tests --extensionTestsPath=$REMOTE_VSCODE/vscode-api-tests/out/workspace-tests $API_TESTS_DEFAULT_EXTRA_ARGS $EXTRA_INTEGRATION_TEST_ARGUMENTS
-after_suite
-
-"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS --folder-uri=$REMOTE_VSCODE/typescript-language-features/test-workspace --enable-proposed-api=vscode.typescript-language-features --extensionDevelopmentPath=$REMOTE_VSCODE/typescript-language-features --extensionTestsPath=$REMOTE_VSCODE/typescript-language-features/out/test/unit $API_TESTS_DEFAULT_EXTRA_ARGS $EXTRA_INTEGRATION_TEST_ARGUMENTS
-after_suite
-
-"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS --folder-uri=$REMOTE_VSCODE/markdown-language-features/test-workspace --extensionDevelopmentPath=$REMOTE_VSCODE/markdown-language-features --extensionTestsPath=$REMOTE_VSCODE/markdown-language-features/out/test $API_TESTS_DEFAULT_EXTRA_ARGS $EXTRA_INTEGRATION_TEST_ARGUMENTS
-after_suite
-
-"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS --folder-uri=$REMOTE_VSCODE/emmet/test-workspace --extensionDevelopmentPath=$REMOTE_VSCODE/emmet --extensionTestsPath=$REMOTE_VSCODE/emmet/out/test $API_TESTS_DEFAULT_EXTRA_ARGS $EXTRA_INTEGRATION_TEST_ARGUMENTS
-after_suite
-
-"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS --folder-uri=$AUTHORITY$(mktemp -d 2>/dev/null) --extensionDevelopmentPath=$REMOTE_VSCODE/git --extensionTestsPath=$REMOTE_VSCODE/git/out/test $API_TESTS_DEFAULT_EXTRA_ARGS $EXTRA_INTEGRATION_TEST_ARGUMENTS
-after_suite
-
-# Clean up
-if [[ "$3" == "" ]]; then
- rm -rf $VSCODEUSERDATADIR
-fi
-
-rm -rf $TESTRESOLVER_DATA_FOLDER
diff --git a/resources/server/test/test-web-integration.bat b/resources/server/test/test-web-integration.bat
deleted file mode 100644
index d063276409b..00000000000
--- a/resources/server/test/test-web-integration.bat
+++ /dev/null
@@ -1,55 +0,0 @@
-@echo off
-setlocal
-
-pushd %~dp0\..\..\..
-
-IF "%~1" == "" (
- set AUTHORITY=vscode-remote://test+test/
- :: backward to forward slashed
- set EXT_PATH=%CD:\=/%/extensions
-
- :: Download nodejs executable for remote
- call yarn gulp node
-) else (
- set AUTHORITY=%1
- set EXT_PATH=%2
-)
-
-set REMOTE_VSCODE=%AUTHORITY%%EXT_PATH%
-
-if "%VSCODE_REMOTE_SERVER_PATH%"=="" (
- echo "Using remote server out of sources for integration web tests"
-) else (
- echo "Using %VSCODE_REMOTE_SERVER_PATH% as server path for web integration tests"
-
- :: Run from a built: need to compile all test extensions
- :: because we run extension tests from their source folders
- :: and the build bundles extensions into .build webpacked
- call yarn gulp compile-extension:vscode-api-tests^
- compile-extension:markdown-language-features^
- compile-extension:typescript-language-features^
- compile-extension:emmet^
- compile-extension:git^
- compile-extension-media
-)
-
-call node .\test\integration\browser\out\index.js --workspacePath=.\extensions\vscode-api-tests\testWorkspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=.\extensions\vscode-api-tests --extensionTestsPath=.\extensions\vscode-api-tests\out\singlefolder-tests %*
-if %errorlevel% neq 0 exit /b %errorlevel%
-
-call node .\test\integration\browser\out\index.js --workspacePath=.\extensions\vscode-api-tests\testworkspace.code-workspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=.\extensions\vscode-api-tests --extensionTestsPath=.\extensions\vscode-api-tests\out\workspace-tests %*
-if %errorlevel% neq 0 exit /b %errorlevel%
-
-call node .\test\integration\browser\out\index.js --workspacePath=.\extensions\typescript-language-features\test-workspace --extensionDevelopmentPath=.\extensions\typescript-language-features --extensionTestsPath=.\extensions\typescript-language-features\out\test\unit %*
-if %errorlevel% neq 0 exit /b %errorlevel%
-
-call node .\test\integration\browser\out\index.js --workspacePath=.\extensions\markdown-language-features\test-workspace --extensionDevelopmentPath=.\extensions\markdown-language-features --extensionTestsPath=.\extensions\markdown-language-features\out\test %*
-if %errorlevel% neq 0 exit /b %errorlevel%
-
-call node .\test\integration\browser\out\index.js --workspacePath=.\extensions\emmet\test-workspace --extensionDevelopmentPath=.\extensions\emmet --extensionTestsPath=.\extensions\emmet\out\test %*
-if %errorlevel% neq 0 exit /b %errorlevel%
-
-for /f "delims=" %%i in ('node -p "require('fs').realpathSync.native(require('os').tmpdir())"') do set TEMPDIR=%%i
-set GITWORKSPACE=%TEMPDIR%\git-%RANDOM%
-mkdir %GITWORKSPACE%
-call node .\test\integration\browser\out\index.js --workspacePath=%GITWORKSPACE% --extensionDevelopmentPath=.\extensions\git --extensionTestsPath=.\extensions\git\out\test --enable-proposed-api=vscode.git %*
-if %errorlevel% neq 0 exit /b %errorlevel%
diff --git a/resources/server/test/test-web-integration.sh b/resources/server/test/test-web-integration.sh
deleted file mode 100755
index 8c6962b4244..00000000000
--- a/resources/server/test/test-web-integration.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/bash
-set -e
-
-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
-
-cd $ROOT
-
-if [ -z "$VSCODE_REMOTE_SERVER_PATH" ]
-then
- echo "Using remote server out of sources for integration web tests"
-else
- echo "Using $VSCODE_REMOTE_SERVER_PATH as server path for web integration tests"
-
- # Run from a built: need to compile all test extensions
- # because we run extension tests from their source folders
- # and the build bundles extensions into .build webpacked
- yarn gulp compile-extension:vscode-api-tests \
- compile-extension:markdown-language-features \
- compile-extension:typescript-language-features \
- compile-extension:emmet \
- compile-extension:git \
- compile-extension-media
-fi
-
-# Tests in the extension host
-node test/integration/browser/out/index.js --workspacePath $ROOT/extensions/vscode-api-tests/testWorkspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=$ROOT/extensions/vscode-api-tests --extensionTestsPath=$ROOT/extensions/vscode-api-tests/out/singlefolder-tests "$@"
-node test/integration/browser/out/index.js --workspacePath $ROOT/extensions/vscode-api-tests/testworkspace.code-workspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=$ROOT/extensions/vscode-api-tests --extensionTestsPath=$ROOT/extensions/vscode-api-tests/out/workspace-tests "$@"
-node test/integration/browser/out/index.js --workspacePath $ROOT/extensions/typescript-language-features/test-workspace --extensionDevelopmentPath=$ROOT/extensions/typescript-language-features --extensionTestsPath=$ROOT/extensions/typescript-language-features/out/test/unit "$@"
-node test/integration/browser/out/index.js --workspacePath $ROOT/extensions/markdown-language-features/test-workspace --extensionDevelopmentPath=$ROOT/extensions/markdown-language-features --extensionTestsPath=$ROOT/extensions/markdown-language-features/out/test "$@"
-node test/integration/browser/out/index.js --workspacePath $ROOT/extensions/emmet/test-workspace --extensionDevelopmentPath=$ROOT/extensions/emmet --extensionTestsPath=$ROOT/extensions/emmet/out/test "$@"
-node test/integration/browser/out/index.js --workspacePath $(mktemp -d 2>/dev/null) --enable-proposed-api=vscode.git --extensionDevelopmentPath=$ROOT/extensions/git --extensionTestsPath=$ROOT/extensions/git/out/test "$@"
diff --git a/resources/web/bin-dev/code-web-playground.js b/resources/web/bin-dev/code-web-playground.js
deleted file mode 100644
index 57a3e4d8d26..00000000000
--- a/resources/web/bin-dev/code-web-playground.js
+++ /dev/null
@@ -1,130 +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 testWeb = require('@vscode/test-web');
-
-const fs = require('fs');
-const path = require('path');
-
-const minimist = require('minimist');
-const fancyLog = require('fancy-log');
-const ansiColors = require('ansi-colors');
-const remote = require('gulp-remote-retry-src');
-const vfs = require('vinyl-fs');
-const opn = require('opn');
-
-const APP_ROOT = path.join(__dirname, '..', '..', '..');
-const WEB_DEV_EXTENSIONS_ROOT = path.join(APP_ROOT, '.build', 'builtInWebDevExtensions');
-
-const WEB_PLAYGROUND_VERSION = '0.0.13';
-
-const args = minimist(process.argv.slice(2), {
- boolean: [
- 'help',
- 'verbose',
- 'open-devtools'
- ],
- string: [
- 'host',
- 'port',
- 'extension',
- 'browserType'
- ],
-});
-
-if (args.help) {
- console.log(
- './scripts/code-web.sh|bat [options]\n' +
- ' --host Server host address\n' +
- ' --port Server port\n' +
- ' --browserType The browser type to launch: `chromium` (default), `firefox`, `webkit` or `none`' +
- ' --extension Path of an extension to include\n' +
- ' --open-devtools Open the dev tools' +
- ' --verbose Print out more information\n' +
- ' --help\n' +
- '[Example]\n' +
- ' ./scripts/code-web.sh|bat --port 8080'
- );
- process.exit(0);
-}
-
-openTestWeb();
-
-
-async function openTestWeb() {
- await ensureWebDevExtensions();
- const extensionPaths = [WEB_DEV_EXTENSIONS_ROOT];
- const extensions = args['extension'];
- if (Array.isArray(extensions)) {
- extensionPaths.push(...extensions);
- } else if (extensions) {
- extensionPaths.push(extensions);
- }
- const host = args.host || 'localhost';
- const port = args.port || 8080;
-
- await testWeb.open({
- browserType: args['browserType'] ?? 'none',
- host,
- port,
- folderUri: 'memfs:///sample-folder',
- vsCodeDevPath: APP_ROOT,
- extensionPaths,
- devTools: !!args['open-devtools'],
- hideServerLog: !args['verbose'],
- verbose: !!args['verbose']
- });
-
-
- if (!args['browserType']) {
- opn(`http://${host}:${port}/`);
- }
-}
-
-async function directoryExists(path) {
- try {
- return (await fs.promises.stat(path)).isDirectory();
- } catch {
- return false;
- }
-}
-
-async function ensureWebDevExtensions() {
-
- // Playground (https://github.com/microsoft/vscode-web-playground)
- const webDevPlaygroundRoot = path.join(WEB_DEV_EXTENSIONS_ROOT, 'vscode-web-playground');
- const webDevPlaygroundExists = await directoryExists(webDevPlaygroundRoot);
-
- let downloadPlayground = false;
- if (webDevPlaygroundExists) {
- try {
- const webDevPlaygroundPackageJson = JSON.parse(((await fs.promises.readFile(path.join(webDevPlaygroundRoot, 'package.json'))).toString()));
- if (webDevPlaygroundPackageJson.version !== WEB_PLAYGROUND_VERSION) {
- downloadPlayground = true;
- }
- } catch (error) {
- downloadPlayground = true;
- }
- } else {
- downloadPlayground = true;
- }
-
- if (downloadPlayground) {
- if (args.verbose) {
- fancyLog(`${ansiColors.magenta('Web Development extensions')}: Downloading vscode-web-playground to ${webDevPlaygroundRoot}`);
- }
- await new Promise((resolve, reject) => {
- remote(['package.json', 'dist/extension.js', 'dist/extension.js.map'], {
- base: 'https://raw.githubusercontent.com/microsoft/vscode-web-playground/main/'
- }).pipe(vfs.dest(webDevPlaygroundRoot)).on('end', resolve).on('error', reject);
- });
- } else {
- if (args.verbose) {
- fancyLog(`${ansiColors.magenta('Web Development extensions')}: Using existing vscode-web-playground in ${webDevPlaygroundRoot}`);
- }
- }
-}