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-02-02 19:48:36 +0300
committerMartin Aeschlimann <martinae@microsoft.com>2022-02-02 19:48:41 +0300
commit47dbe8bbf6dde902a35fbfcd0e533243b91b3024 (patch)
treebb630ed404e766365bf54a6a4deacf813847f401 /scripts
parentaacef0b1374ef02a878bee89f326bd0c74f9f448 (diff)
code-web forward to @vscode/test-web
Diffstat (limited to 'scripts')
-rw-r--r--scripts/code-server.js92
-rw-r--r--scripts/code-web.js137
2 files changed, 129 insertions, 100 deletions
diff --git a/scripts/code-server.js b/scripts/code-server.js
index c7ecdd8c07c..8b8deef7bfc 100644
--- a/scripts/code-server.js
+++ b/scripts/code-server.js
@@ -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'
- ],
-});
-
-if (args.help) {
- console.log(
- './scripts/code-server.sh|bat [options]\n' +
- ' --launch Opens a browser'
- );
- // more help options will be printed by startServer
-}
+function main() {
-const serverArgs = process.argv.slice(2).filter(v => v !== '--launch');
+ const args = minimist(process.argv.slice(2), {
+ boolean: [
+ 'help',
+ 'launch'
+ ],
+ string: [
+ 'host',
+ 'port',
+ 'driver',
+ 'connection-token',
+ 'server-data-dir'
+ ],
+ });
-const HOST = args['host'] ?? 'localhost';
-const PORT = args['port'] ?? '9888';
-const TOKEN = args['connection-token'] ?? String(crypto.randomInt(0xffffffff));
+ if (args.help) {
+ console.log(
+ './scripts/code-server.sh|bat [options]\n' +
+ ' --launch Opens a browser'
+ );
+ startServer(['--help']);
+ return
+ }
-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 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 env = { ...process.env };
+function startServer(programArgs) {
+ const env = { ...process.env };
-const entryPoint = path.join(__dirname, '..', 'out', 'server-main.js');
-startServer();
+ const entryPoint = path.join(__dirname, '..', 'out', 'server-main.js');
-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();
+
diff --git a/scripts/code-web.js b/scripts/code-web.js
index 5f3040c04a0..6603f67ec40 100644
--- a/scripts/code-web.js
+++ b/scripts/code-web.js
@@ -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,69 +23,88 @@ 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'
- ],
-});
-
-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);
-}
+async function main() {
+
+ const args = minimist(process.argv.slice(2), {
+ boolean: [
+ 'help',
+ 'playground'
+ ],
+ string: [
+ 'host',
+ 'port',
+ 'extensionPath',
+ 'browserType'
+ ],
+ });
+
+ 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);
+ }
-openTestWeb();
+ const serverArgs = [];
+ const HOST = args['host'] ?? 'localhost';
+ const PORT = args['port'] ?? '8080';
-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);
+ if (args['host'] === undefined) {
+ serverArgs.push('--host', HOST);
+ }
+ if (args['port'] === undefined) {
+ serverArgs.push('--port', PORT);
}
- 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['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']) {
- opn(`http://${host}:${port}/`);
+ 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) {
try {
return (await fs.promises.stat(path)).isDirectory();
@@ -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();