mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
code-web forward to @vscode/test-web
This commit is contained in:
@@ -124,7 +124,7 @@
|
||||
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
||||
"@typescript-eslint/parser": "^5.10.0",
|
||||
"@vscode/telemetry-extractor": "^1.9.5",
|
||||
"@vscode/test-web": "^0.0.19",
|
||||
"@vscode/test-web": "^0.0.21",
|
||||
"ansi-colors": "^3.2.3",
|
||||
"asar": "^3.0.3",
|
||||
"chromium-pickle-js": "^0.2.0",
|
||||
|
||||
@@ -7,57 +7,64 @@
|
||||
|
||||
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'
|
||||
],
|
||||
});
|
||||
function main() {
|
||||
|
||||
if (args.help) {
|
||||
console.log(
|
||||
'./scripts/code-server.sh|bat [options]\n' +
|
||||
' --launch Opens a browser'
|
||||
);
|
||||
// more help options will be printed by startServer
|
||||
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'
|
||||
);
|
||||
startServer(['--help']);
|
||||
return
|
||||
}
|
||||
|
||||
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['without-connection-token']) {
|
||||
serverArgs.push('--connection-token', TOKEN);
|
||||
}
|
||||
if (args['host'] === undefined) {
|
||||
serverArgs.push('--host', HOST);
|
||||
}
|
||||
if (args['port'] === undefined) {
|
||||
serverArgs.push('--port', PORT);
|
||||
}
|
||||
|
||||
startServer(serverArgs);
|
||||
if (args['launch']) {
|
||||
opn(`http://${HOST}:${PORT}/?tkn=${TOKEN}`);
|
||||
}
|
||||
}
|
||||
|
||||
const serverArgs = process.argv.slice(2).filter(v => v !== '--launch');
|
||||
function startServer(programArgs) {
|
||||
const env = { ...process.env };
|
||||
|
||||
const HOST = args['host'] ?? 'localhost';
|
||||
const PORT = args['port'] ?? '9888';
|
||||
const TOKEN = args['connection-token'] ?? String(crypto.randomInt(0xffffffff));
|
||||
const entryPoint = path.join(__dirname, '..', 'out', 'server-main.js');
|
||||
|
||||
if (args['connection-token'] === undefined && args['connection-token-file'] === undefined && !args['without-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 };
|
||||
|
||||
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, stdio: 'inherit' });
|
||||
console.log(`Starting server: ${entryPoint} ${programArgs.join(' ')}`);
|
||||
const proc = cp.spawn(process.execPath, [entryPoint, ...programArgs], { env, stdio: 'inherit' });
|
||||
|
||||
proc.on('exit', (code) => process.exit(code));
|
||||
|
||||
@@ -73,6 +80,5 @@ function startServer() {
|
||||
|
||||
}
|
||||
|
||||
if (args['launch']) {
|
||||
opn(`http://${HOST}:${PORT}/?tkn=${TOKEN}`);
|
||||
}
|
||||
main();
|
||||
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
|
||||
// @ts-check
|
||||
|
||||
const testWeb = require('@vscode/test-web');
|
||||
const testWebLocation = require.resolve('@vscode/test-web');
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const cp = require('child_process');
|
||||
|
||||
const minimist = require('minimist');
|
||||
const fancyLog = require('fancy-log');
|
||||
@@ -22,67 +23,86 @@ const WEB_DEV_EXTENSIONS_ROOT = path.join(APP_ROOT, '.build', 'builtInWebDevExte
|
||||
|
||||
const WEB_PLAYGROUND_VERSION = '0.0.13';
|
||||
|
||||
const args = minimist(process.argv.slice(2), {
|
||||
boolean: [
|
||||
'help',
|
||||
'verbose',
|
||||
'open-devtools'
|
||||
],
|
||||
string: [
|
||||
'host',
|
||||
'port',
|
||||
'extension',
|
||||
'browserType'
|
||||
],
|
||||
});
|
||||
async function main() {
|
||||
|
||||
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`, `firefox`, `webkit` or `none`. If not specified the OS default browser will be used.' +
|
||||
' --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']
|
||||
const args = minimist(process.argv.slice(2), {
|
||||
boolean: [
|
||||
'help',
|
||||
'playground'
|
||||
],
|
||||
string: [
|
||||
'host',
|
||||
'port',
|
||||
'extensionPath',
|
||||
'browserType'
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
if (!args['browserType']) {
|
||||
opn(`http://${host}:${port}/`);
|
||||
if (args.help) {
|
||||
console.log(
|
||||
'./scripts/code-web.sh|bat [options]\n' +
|
||||
' --playground Include the vscode-web-playground extension\n'
|
||||
);
|
||||
startServer(['--help']);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const serverArgs = [];
|
||||
|
||||
const HOST = args['host'] ?? 'localhost';
|
||||
const PORT = args['port'] ?? '8080';
|
||||
|
||||
if (args['host'] === undefined) {
|
||||
serverArgs.push('--host', HOST);
|
||||
}
|
||||
if (args['port'] === undefined) {
|
||||
serverArgs.push('--port', PORT);
|
||||
}
|
||||
|
||||
if (args['playground'] || args['_'].length === 0) {
|
||||
serverArgs.push('--extensionPath', WEB_DEV_EXTENSIONS_ROOT);
|
||||
serverArgs.push('--folder-uri', 'memfs:///sample-folder');
|
||||
await ensureWebDevExtensions(args['verbose'])
|
||||
}
|
||||
|
||||
let openSystemBrowser = false;
|
||||
if (!args['browserType']) {
|
||||
serverArgs.push('--browserType', 'none');
|
||||
openSystemBrowser = true;
|
||||
}
|
||||
|
||||
if (!args['verbose'] && args['hideServerLog'] === undefined) {
|
||||
serverArgs.push('--hideServerLog');
|
||||
}
|
||||
|
||||
serverArgs.push('--sourcesPath', APP_ROOT);
|
||||
|
||||
serverArgs.push(...process.argv.slice(2).filter(v => v !== '--playground'))
|
||||
|
||||
|
||||
startServer(serverArgs);
|
||||
if (openSystemBrowser) {
|
||||
opn(`http://${HOST}:${PORT}/`);
|
||||
}
|
||||
}
|
||||
|
||||
function startServer(runnerArguments) {
|
||||
const env = { ...process.env };
|
||||
|
||||
console.log(`Starting @vscode/test-web: ${testWebLocation} ${runnerArguments.join(' ')}`);
|
||||
const proc = cp.spawn(process.execPath, [testWebLocation, ...runnerArguments], { env, stdio: 'inherit' });
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
|
||||
async function directoryExists(path) {
|
||||
@@ -93,7 +113,7 @@ async function directoryExists(path) {
|
||||
}
|
||||
}
|
||||
|
||||
async function ensureWebDevExtensions() {
|
||||
async function ensureWebDevExtensions(verbose) {
|
||||
|
||||
// Playground (https://github.com/microsoft/vscode-web-playground)
|
||||
const webDevPlaygroundRoot = path.join(WEB_DEV_EXTENSIONS_ROOT, 'vscode-web-playground');
|
||||
@@ -114,7 +134,7 @@ async function ensureWebDevExtensions() {
|
||||
}
|
||||
|
||||
if (downloadPlayground) {
|
||||
if (args.verbose) {
|
||||
if (verbose) {
|
||||
fancyLog(`${ansiColors.magenta('Web Development extensions')}: Downloading vscode-web-playground to ${webDevPlaygroundRoot}`);
|
||||
}
|
||||
await new Promise((resolve, reject) => {
|
||||
@@ -123,8 +143,11 @@ async function ensureWebDevExtensions() {
|
||||
}).pipe(vfs.dest(webDevPlaygroundRoot)).on('end', resolve).on('error', reject);
|
||||
});
|
||||
} else {
|
||||
if (args.verbose) {
|
||||
if (verbose) {
|
||||
fancyLog(`${ansiColors.magenta('Web Development extensions')}: Using existing vscode-web-playground in ${webDevPlaygroundRoot}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
main();
|
||||
|
||||
@@ -1585,10 +1585,10 @@
|
||||
ts-morph "^12.2.0"
|
||||
vscode-ripgrep "^1.12.1"
|
||||
|
||||
"@vscode/test-web@^0.0.19":
|
||||
version "0.0.19"
|
||||
resolved "https://registry.yarnpkg.com/@vscode/test-web/-/test-web-0.0.19.tgz#2e2b030bca049c31f56bb73709b15c03b04bcaa1"
|
||||
integrity sha512-7Idk5qmShFCG65OMg7zB5028L38CVk5StKONgnzJNDjKXMj4BOch5CMAK6ad1P+oah94EYVSzGrX/AF1EgpxWA==
|
||||
"@vscode/test-web@^0.0.21":
|
||||
version "0.0.21"
|
||||
resolved "https://registry.yarnpkg.com/@vscode/test-web/-/test-web-0.0.21.tgz#b1dd359c6d9903c81df9e9d95464b36aeec39bd2"
|
||||
integrity sha512-4JYWCYrG8pb76MgI2W0vkN1a3numZDLH6tpz6OPmfx6YsI8Z+CHyiWqAGhIQOlXqsquvsyR9mhPe15yGAEupMw==
|
||||
dependencies:
|
||||
"@koa/router" "^10.1.1"
|
||||
decompress "^4.2.1"
|
||||
|
||||
Reference in New Issue
Block a user