web - move playground out of sources

We will consume the playground from https://github.com/microsoft/vscode-web-playground going forward.
This commit is contained in:
Benjamin Pasero
2020-08-18 09:18:23 +02:00
parent 3d5b2fecf2
commit 4491427ac7
15 changed files with 47 additions and 4988 deletions
+47 -1
View File
@@ -16,14 +16,19 @@ const opn = require('opn');
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 extensions = require('../../build/lib/extensions');
const APP_ROOT = path.join(__dirname, '..', '..');
const BUILTIN_EXTENSIONS_ROOT = path.join(APP_ROOT, 'extensions');
const BUILTIN_MARKETPLACE_EXTENSIONS_ROOT = path.join(APP_ROOT, '.build', 'builtInExtensions');
const WEB_DEV_EXTENSIONS_ROOT = path.join(APP_ROOT, '.build', 'builtInWebDevExtensions');
const WEB_MAIN = path.join(APP_ROOT, 'src', 'vs', 'code', 'browser', 'workbench', 'workbench-dev.html');
const WEB_PLAYGROUND_VERSION = '0.0.1';
const args = minimist(process.argv, {
boolean: [
'no-launch',
@@ -72,9 +77,10 @@ async function getBuiltInExtensionInfos() {
/** @type {Object.<string, string>} */
const locations = {};
const [localExtensions, marketplaceExtensions] = await Promise.all([
const [localExtensions, marketplaceExtensions, webDevExtensions] = await Promise.all([
extensions.scanBuiltinExtensions(BUILTIN_EXTENSIONS_ROOT),
extensions.scanBuiltinExtensions(BUILTIN_MARKETPLACE_EXTENSIONS_ROOT),
ensureWebDevExtensions().then(() => extensions.scanBuiltinExtensions(WEB_DEV_EXTENSIONS_ROOT))
]);
for (const ext of localExtensions) {
allExtensions.push(ext);
@@ -84,6 +90,10 @@ async function getBuiltInExtensionInfos() {
allExtensions.push(ext);
locations[ext.extensionPath] = path.join(BUILTIN_MARKETPLACE_EXTENSIONS_ROOT, ext.extensionPath);
}
for (const ext of webDevExtensions) {
allExtensions.push(ext);
locations[ext.extensionPath] = path.join(WEB_DEV_EXTENSIONS_ROOT, ext.extensionPath);
}
for (const ext of allExtensions) {
if (ext.packageJSON.browser) {
let mainFilePath = path.join(locations[ext.extensionPath], ext.packageJSON.browser);
@@ -98,6 +108,42 @@ async function getBuiltInExtensionInfos() {
return { extensions: allExtensions, locations };
}
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 exists(webDevPlaygroundRoot);
let downloadPlayground = false;
if (webDevPlaygroundExists) {
try {
const webDevPlaygroundPackageJson = JSON.parse(((await 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}`);
}
}
}
async function getDefaultExtensionInfos() {
const extensions = [];