@vscode/test-web 0.0.11 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.yarnrc +1 -0
- package/CHANGELOG.md +11 -0
- package/README.md +41 -28
- package/fs-provider/dist/extension-web.js +3 -3
- package/fs-provider/dist/fsExtensionMain.js +569 -0
- package/fs-provider/package.json +5 -5
- package/out/index.d.ts +18 -1
- package/out/index.js +161 -72
- package/out/server/app.js +11 -7
- package/out/server/download.js +6 -6
- package/out/server/main.js +1 -1
- package/out/server/mounts.js +3 -2
- package/out/server/workbench.js +15 -12
- package/package.json +16 -16
package/out/index.js
CHANGED
|
@@ -18,89 +18,107 @@ const path = require("path");
|
|
|
18
18
|
* @param options The options defining browser type, extension and test location.
|
|
19
19
|
*/
|
|
20
20
|
async function runTests(options) {
|
|
21
|
-
var _a;
|
|
22
21
|
const config = {
|
|
23
22
|
extensionDevelopmentPath: options.extensionDevelopmentPath,
|
|
24
23
|
extensionTestsPath: options.extensionTestsPath,
|
|
25
24
|
build: await getBuild(options.version),
|
|
26
25
|
folderUri: options.folderUri,
|
|
27
|
-
folderMountPath: options.folderPath
|
|
26
|
+
folderMountPath: options.folderPath,
|
|
27
|
+
hideServerLog: true,
|
|
28
|
+
extensionPaths: options.extensionPaths
|
|
28
29
|
};
|
|
29
30
|
const port = 3000;
|
|
30
|
-
const server = await main_1.runServer(port, config);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
const server = await (0, main_1.runServer)(port, config);
|
|
32
|
+
return new Promise(async (s, e) => {
|
|
33
|
+
const endpoint = `http://localhost:${port}`;
|
|
34
|
+
const context = await openBrowser(endpoint, options);
|
|
35
|
+
context.once('close', () => server.close());
|
|
36
|
+
await context.exposeFunction('codeAutomationLog', (type, args) => {
|
|
37
|
+
console[type](...args);
|
|
38
|
+
});
|
|
39
|
+
await context.exposeFunction('codeAutomationExit', async (code) => {
|
|
40
|
+
var _a;
|
|
41
|
+
try {
|
|
42
|
+
await ((_a = context.browser()) === null || _a === void 0 ? void 0 : _a.close());
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.error(`Error when closing browser: ${error}`);
|
|
46
|
+
}
|
|
47
|
+
server.close();
|
|
48
|
+
if (code === 0) {
|
|
49
|
+
s();
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
e(new Error('Test failed'));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
38
55
|
});
|
|
39
|
-
server.close();
|
|
40
|
-
if (result) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
throw new Error('Test failed');
|
|
44
56
|
}
|
|
45
57
|
exports.runTests = runTests;
|
|
46
58
|
async function getBuild(version) {
|
|
47
59
|
if (version === 'sources') {
|
|
48
60
|
return { type: 'sources' };
|
|
49
61
|
}
|
|
50
|
-
return await download_1.downloadAndUnzipVSCode(version === 'stable' ? 'stable' : 'insider');
|
|
62
|
+
return await (0, download_1.downloadAndUnzipVSCode)(version === 'stable' ? 'stable' : 'insider');
|
|
51
63
|
}
|
|
52
64
|
async function open(options) {
|
|
53
|
-
var _a;
|
|
54
65
|
const config = {
|
|
55
66
|
extensionDevelopmentPath: options.extensionDevelopmentPath,
|
|
67
|
+
extensionTestsPath: options.extensionTestsPath,
|
|
56
68
|
build: await getBuild(options.version),
|
|
57
69
|
folderUri: options.folderUri,
|
|
58
|
-
folderMountPath: options.folderPath
|
|
70
|
+
folderMountPath: options.folderPath,
|
|
71
|
+
extensionPaths: options.extensionPaths
|
|
59
72
|
};
|
|
60
73
|
const port = 3000;
|
|
61
|
-
await main_1.runServer(port, config);
|
|
74
|
+
const server = await (0, main_1.runServer)(port, config);
|
|
62
75
|
const endpoint = `http://localhost:${port}`;
|
|
63
|
-
await
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
const context = await openBrowser(endpoint, options);
|
|
77
|
+
context.once('close', () => server.close());
|
|
78
|
+
return {
|
|
79
|
+
dispose: () => {
|
|
80
|
+
var _a;
|
|
81
|
+
server.close();
|
|
82
|
+
(_a = context.browser()) === null || _a === void 0 ? void 0 : _a.close();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
69
85
|
}
|
|
70
86
|
exports.open = open;
|
|
71
87
|
const width = 1200;
|
|
72
88
|
const height = 800;
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
await browser.close();
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
console.error(`Error when closing browser: ${error}`);
|
|
89
|
+
async function openBrowser(endpoint, options) {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
const args = [];
|
|
92
|
+
if (process.platform === 'linux' && options.browserType === 'chromium') {
|
|
93
|
+
args.push('--no-sandbox');
|
|
94
|
+
}
|
|
95
|
+
if (options.waitForDebugger) {
|
|
96
|
+
args.push(`--remote-debugging-port=${options.waitForDebugger}`);
|
|
97
|
+
}
|
|
98
|
+
const headless = (_a = options.headless) !== null && _a !== void 0 ? _a : options.extensionDevelopmentPath !== undefined;
|
|
99
|
+
const browser = await playwright[options.browserType].launch({ headless, args, devtools: options.devTools });
|
|
100
|
+
const context = await browser.newContext();
|
|
101
|
+
if (options.permissions) {
|
|
102
|
+
context.grantPermissions(options.permissions);
|
|
103
|
+
}
|
|
104
|
+
// forcefully close browser if last page is closed. workaround for https://github.com/microsoft/playwright/issues/2946
|
|
105
|
+
let openPages = 0;
|
|
106
|
+
context.on('page', page => {
|
|
107
|
+
openPages++;
|
|
108
|
+
page.once('close', () => {
|
|
109
|
+
openPages--;
|
|
110
|
+
if (openPages === 0) {
|
|
111
|
+
browser.close();
|
|
100
112
|
}
|
|
101
|
-
s(code === 0);
|
|
102
113
|
});
|
|
103
114
|
});
|
|
115
|
+
const page = (_b = context.pages()[0]) !== null && _b !== void 0 ? _b : await context.newPage();
|
|
116
|
+
if (options.waitForDebugger) {
|
|
117
|
+
await page.waitForFunction(() => '__jsDebugIsReady' in globalThis);
|
|
118
|
+
}
|
|
119
|
+
await page.setViewportSize({ width, height });
|
|
120
|
+
await page.goto(endpoint);
|
|
121
|
+
return context;
|
|
104
122
|
}
|
|
105
123
|
function validateStringOrUndefined(options, name) {
|
|
106
124
|
const value = options[name];
|
|
@@ -125,7 +143,7 @@ function validateBooleanOrUndefined(options, name) {
|
|
|
125
143
|
process.exit(-1);
|
|
126
144
|
}
|
|
127
145
|
function valdiateBrowserType(browserType) {
|
|
128
|
-
if (browserType ===
|
|
146
|
+
if (browserType === undefined) {
|
|
129
147
|
return 'chromium';
|
|
130
148
|
}
|
|
131
149
|
if ((typeof browserType === 'string') && ['chromium', 'firefox', 'webkit'].includes(browserType)) {
|
|
@@ -135,16 +153,56 @@ function valdiateBrowserType(browserType) {
|
|
|
135
153
|
showHelp();
|
|
136
154
|
process.exit(-1);
|
|
137
155
|
}
|
|
156
|
+
function valdiatePermissions(permissions) {
|
|
157
|
+
if (permissions === undefined) {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
function isValidPermission(p) {
|
|
161
|
+
return typeof p === 'string';
|
|
162
|
+
}
|
|
163
|
+
if (isValidPermission(permissions)) {
|
|
164
|
+
return [permissions];
|
|
165
|
+
}
|
|
166
|
+
if (Array.isArray(permissions) && permissions.every(isValidPermission)) {
|
|
167
|
+
return permissions;
|
|
168
|
+
}
|
|
169
|
+
console.log(`Invalid permission`);
|
|
170
|
+
showHelp();
|
|
171
|
+
process.exit(-1);
|
|
172
|
+
}
|
|
173
|
+
async function valdiateExtensionPaths(extensionPaths) {
|
|
174
|
+
if (extensionPaths === undefined) {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
if (!Array.isArray(extensionPaths)) {
|
|
178
|
+
extensionPaths = [extensionPaths];
|
|
179
|
+
}
|
|
180
|
+
if (Array.isArray(extensionPaths)) {
|
|
181
|
+
const res = [];
|
|
182
|
+
for (const extensionPath of extensionPaths) {
|
|
183
|
+
if (typeof extensionPath === 'string') {
|
|
184
|
+
res.push(await validatePath(extensionPath));
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return res;
|
|
191
|
+
}
|
|
192
|
+
console.log(`Invalid extensionPath`);
|
|
193
|
+
showHelp();
|
|
194
|
+
process.exit(-1);
|
|
195
|
+
}
|
|
138
196
|
async function validatePath(loc, isFile) {
|
|
139
197
|
loc = path.resolve(loc);
|
|
140
198
|
if (isFile) {
|
|
141
|
-
if (!await download_1.fileExists(loc)) {
|
|
199
|
+
if (!await (0, download_1.fileExists)(loc)) {
|
|
142
200
|
console.log(`'${loc}' must be an existing file.`);
|
|
143
201
|
process.exit(-1);
|
|
144
202
|
}
|
|
145
203
|
}
|
|
146
204
|
else {
|
|
147
|
-
if (!await download_1.directoryExists(loc)) {
|
|
205
|
+
if (!await (0, download_1.directoryExists)(loc)) {
|
|
148
206
|
console.log(`'${loc}' must be an existing folder.`);
|
|
149
207
|
process.exit(-1);
|
|
150
208
|
}
|
|
@@ -170,24 +228,49 @@ function validatePortNumber(port) {
|
|
|
170
228
|
}
|
|
171
229
|
function showHelp() {
|
|
172
230
|
console.log('Usage:');
|
|
173
|
-
console.log(` --browserType 'chromium' | 'firefox' | 'webkit': The browser to launch`);
|
|
174
|
-
console.log(` --extensionDevelopmentPath path
|
|
175
|
-
console.log(` --extensionTestsPath path
|
|
176
|
-
console.log(` --version
|
|
177
|
-
console.log(` --open-devtools
|
|
178
|
-
console.log(` --headless
|
|
179
|
-
console.log(`
|
|
231
|
+
console.log(` --browserType 'chromium' | 'firefox' | 'webkit': The browser to launch. [Optional, default 'chromium']`);
|
|
232
|
+
console.log(` --extensionDevelopmentPath path: A path pointing to an extension under development to include. [Optional]`);
|
|
233
|
+
console.log(` --extensionTestsPath path: A path to a test module to run. [Optional]`);
|
|
234
|
+
console.log(` --version 'insiders' | 'stable' | 'sources' [Optional, default 'insiders']`);
|
|
235
|
+
console.log(` --open-devtools: If set, opens the dev tools [Optional]`);
|
|
236
|
+
console.log(` --headless: Whether to hide the browser. Defaults to true when an extensionTestsPath is provided, otherwise false. [Optional]`);
|
|
237
|
+
console.log(` --hideServerLog: Whether to hide the server log. Defaults to true when an extensionTestsPath is provided, otherwise false. [Optional]`);
|
|
238
|
+
console.log(` --permission: Permission granted in the opened browser: e.g. 'clipboard-read', 'clipboard-write': [Optional, Multiple]`);
|
|
239
|
+
console.log(` --folder-uri: workspace to open VS Code on. Ignored when folderPath is provided [Optional]`);
|
|
240
|
+
console.log(` --extensionPath: A path pointing to a folder containing additional extensions to include [Optional, Multiple]`);
|
|
241
|
+
console.log(` folderPath. A local folder to open VS Code on. The folder content will be available as a virtual file system. [Optional]`);
|
|
180
242
|
}
|
|
181
243
|
async function cliMain() {
|
|
182
|
-
|
|
244
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
245
|
+
const manifest = require('../package.json');
|
|
246
|
+
console.log(`${manifest.name}: ${manifest.version}`);
|
|
247
|
+
const options = {
|
|
248
|
+
string: ['extensionDevelopmentPath', 'extensionTestsPath', 'browserType', 'version', 'waitForDebugger', 'folder-uri', 'permission', 'extensionPath'],
|
|
249
|
+
boolean: ['open-devtools', 'headless', 'hideServerLog', 'help'],
|
|
250
|
+
unknown: arg => {
|
|
251
|
+
if (arg.startsWith('-')) {
|
|
252
|
+
console.log(`Unknown argument ${arg}`);
|
|
253
|
+
showHelp();
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
};
|
|
183
259
|
const args = minimist(process.argv.slice(2), options);
|
|
260
|
+
if (args.help) {
|
|
261
|
+
showHelp();
|
|
262
|
+
process.exit();
|
|
263
|
+
}
|
|
184
264
|
const browserType = valdiateBrowserType(args.browserType);
|
|
185
|
-
const version = validateVersion(args.version);
|
|
186
265
|
const extensionTestsPath = await validatePathOrUndefined(args, 'extensionTestsPath', true);
|
|
187
266
|
const extensionDevelopmentPath = await validatePathOrUndefined(args, 'extensionDevelopmentPath');
|
|
188
|
-
const
|
|
267
|
+
const extensionPaths = await valdiateExtensionPaths(args.extensionPath);
|
|
268
|
+
const version = validateVersion(args.version);
|
|
189
269
|
const devTools = validateBooleanOrUndefined(args, 'open-devtools');
|
|
190
|
-
const
|
|
270
|
+
const headless = validateBooleanOrUndefined(args, 'headless');
|
|
271
|
+
const permissions = valdiatePermissions(args.permission);
|
|
272
|
+
const hideServerLog = validateBooleanOrUndefined(args, 'hideServerLog');
|
|
273
|
+
const waitForDebugger = validatePortNumber(args.waitForDebugger);
|
|
191
274
|
let folderUri = validateStringOrUndefined(args, 'folder-uri');
|
|
192
275
|
let folderPath;
|
|
193
276
|
const inputs = args._;
|
|
@@ -197,8 +280,8 @@ async function cliMain() {
|
|
|
197
280
|
folderPath = input;
|
|
198
281
|
if (folderUri) {
|
|
199
282
|
console.log(`Local folder provided as input, ignoring 'folder-uri'`);
|
|
283
|
+
folderUri = undefined;
|
|
200
284
|
}
|
|
201
|
-
folderUri = `vscode-test-web://mount/`;
|
|
202
285
|
}
|
|
203
286
|
}
|
|
204
287
|
if (extensionTestsPath) {
|
|
@@ -208,10 +291,13 @@ async function cliMain() {
|
|
|
208
291
|
browserType,
|
|
209
292
|
version,
|
|
210
293
|
devTools,
|
|
211
|
-
waitForDebugger
|
|
294
|
+
waitForDebugger,
|
|
212
295
|
folderUri,
|
|
213
296
|
folderPath,
|
|
214
|
-
headless
|
|
297
|
+
headless,
|
|
298
|
+
hideServerLog,
|
|
299
|
+
permissions,
|
|
300
|
+
extensionPaths
|
|
215
301
|
});
|
|
216
302
|
}
|
|
217
303
|
else {
|
|
@@ -220,10 +306,13 @@ async function cliMain() {
|
|
|
220
306
|
browserType,
|
|
221
307
|
version,
|
|
222
308
|
devTools,
|
|
223
|
-
waitForDebugger
|
|
309
|
+
waitForDebugger,
|
|
224
310
|
folderUri,
|
|
225
311
|
folderPath,
|
|
226
|
-
headless
|
|
312
|
+
headless,
|
|
313
|
+
hideServerLog,
|
|
314
|
+
permissions,
|
|
315
|
+
extensionPaths
|
|
227
316
|
});
|
|
228
317
|
}
|
|
229
318
|
}
|
package/out/server/app.js
CHANGED
|
@@ -13,17 +13,15 @@ const path = require("path");
|
|
|
13
13
|
const mounts_1 = require("./mounts");
|
|
14
14
|
async function createApp(config) {
|
|
15
15
|
const app = new Koa();
|
|
16
|
-
|
|
16
|
+
if (!config.hideServerLog) {
|
|
17
|
+
app.use(morgan('dev'));
|
|
18
|
+
}
|
|
17
19
|
// this is here such that the iframe worker can fetch the extension files
|
|
18
20
|
app.use((ctx, next) => {
|
|
19
21
|
ctx.set('Access-Control-Allow-Origin', '*');
|
|
20
22
|
return next();
|
|
21
23
|
});
|
|
22
24
|
app.use(kmount('/static', kstatic(path.join(__dirname, '../static'))));
|
|
23
|
-
if (config.extensionPath) {
|
|
24
|
-
console.log('Serving extensions from ' + config.extensionPath);
|
|
25
|
-
app.use(kmount('/static/extensions', kstatic(config.extensionPath, { hidden: true })));
|
|
26
|
-
}
|
|
27
25
|
if (config.extensionDevelopmentPath) {
|
|
28
26
|
console.log('Serving dev extensions from ' + config.extensionDevelopmentPath);
|
|
29
27
|
app.use(kmount('/static/devextensions', kstatic(config.extensionDevelopmentPath, { hidden: true })));
|
|
@@ -31,8 +29,14 @@ async function createApp(config) {
|
|
|
31
29
|
if (config.build.type === 'static') {
|
|
32
30
|
app.use(kmount('/static/build', kstatic(config.build.location, { hidden: true })));
|
|
33
31
|
}
|
|
34
|
-
mounts_1.configureMounts(config, app);
|
|
35
|
-
|
|
32
|
+
(0, mounts_1.configureMounts)(config, app);
|
|
33
|
+
if (config.extensionPaths) {
|
|
34
|
+
config.extensionPaths.forEach((extensionPath, index) => {
|
|
35
|
+
console.log('Serving additional built-in extensions from ' + extensionPath);
|
|
36
|
+
app.use(kmount(`/static/extensions/${index}`, kstatic(extensionPath, { hidden: true })));
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
app.use((0, workbench_1.default)(config));
|
|
36
40
|
return app;
|
|
37
41
|
}
|
|
38
42
|
exports.default = createApp;
|
package/out/server/download.js
CHANGED
|
@@ -29,7 +29,7 @@ async function download(downloadUrl, destination, message) {
|
|
|
29
29
|
const total = Number(res.headers['content-length']);
|
|
30
30
|
let received = 0;
|
|
31
31
|
let timeout;
|
|
32
|
-
const outStream = fs_1.createWriteStream(destination);
|
|
32
|
+
const outStream = (0, fs_1.createWriteStream)(destination);
|
|
33
33
|
outStream.on('close', () => resolve(destination));
|
|
34
34
|
outStream.on('error', reject);
|
|
35
35
|
res.on('data', chunk => {
|
|
@@ -54,7 +54,7 @@ async function download(downloadUrl, destination, message) {
|
|
|
54
54
|
}
|
|
55
55
|
async function unzip(source, destination, message) {
|
|
56
56
|
process.stdout.write(message);
|
|
57
|
-
if (!fs_1.existsSync(destination)) {
|
|
57
|
+
if (!(0, fs_1.existsSync)(destination)) {
|
|
58
58
|
await fs_1.promises.mkdir(destination, { recursive: true });
|
|
59
59
|
}
|
|
60
60
|
await decompress(source, destination, {
|
|
@@ -69,10 +69,10 @@ async function downloadAndUnzipVSCode(quality) {
|
|
|
69
69
|
const info = await getLatestVersion(quality);
|
|
70
70
|
const folderName = `vscode-web-${quality}-${info.version}`;
|
|
71
71
|
const downloadedPath = path.resolve(vscodeTestDir, folderName);
|
|
72
|
-
if (fs_1.existsSync(downloadedPath) && fs_1.existsSync(path.join(downloadedPath, 'version'))) {
|
|
73
|
-
return { type: 'static', location: downloadedPath };
|
|
72
|
+
if ((0, fs_1.existsSync)(downloadedPath) && (0, fs_1.existsSync)(path.join(downloadedPath, 'version'))) {
|
|
73
|
+
return { type: 'static', location: downloadedPath, quality, version: info.version };
|
|
74
74
|
}
|
|
75
|
-
if (fs_1.existsSync(vscodeTestDir)) {
|
|
75
|
+
if ((0, fs_1.existsSync)(vscodeTestDir)) {
|
|
76
76
|
await fs_1.promises.rmdir(vscodeTestDir, { recursive: true, maxRetries: 5 });
|
|
77
77
|
}
|
|
78
78
|
await fs_1.promises.mkdir(vscodeTestDir, { recursive: true });
|
|
@@ -95,7 +95,7 @@ async function downloadAndUnzipVSCode(quality) {
|
|
|
95
95
|
// ignore
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
return { type: 'static', location: downloadedPath };
|
|
98
|
+
return { type: 'static', location: downloadedPath, quality, version: info.version };
|
|
99
99
|
}
|
|
100
100
|
exports.downloadAndUnzipVSCode = downloadAndUnzipVSCode;
|
|
101
101
|
async function fetch(api) {
|
package/out/server/main.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.runServer = void 0;
|
|
8
8
|
const app_1 = require("./app");
|
|
9
9
|
async function runServer(port, config) {
|
|
10
|
-
const app = await app_1.default(config);
|
|
10
|
+
const app = await (0, app_1.default)(config);
|
|
11
11
|
const server = app.listen(port);
|
|
12
12
|
console.log(`Listening on http://localhost:${port}`);
|
|
13
13
|
return server;
|
package/out/server/mounts.js
CHANGED
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.configureMounts = exports.fsProviderExtensionPrefix = void 0;
|
|
7
|
+
exports.configureMounts = exports.fsProviderFolderUri = exports.fsProviderExtensionPrefix = void 0;
|
|
8
8
|
const kstatic = require("koa-static");
|
|
9
9
|
const kmount = require("koa-mount");
|
|
10
10
|
const Router = require("@koa/router");
|
|
11
11
|
const fs_1 = require("fs");
|
|
12
12
|
const path = require("path");
|
|
13
13
|
const mountPrefix = '/static/mount';
|
|
14
|
-
exports.fsProviderExtensionPrefix = '/static/
|
|
14
|
+
exports.fsProviderExtensionPrefix = '/static/extensions/fs';
|
|
15
|
+
exports.fsProviderFolderUri = 'vscode-test-web://mount/';
|
|
15
16
|
function configureMounts(config, app) {
|
|
16
17
|
const folderMountPath = config.folderMountPath;
|
|
17
18
|
if (folderMountPath) {
|
package/out/server/workbench.js
CHANGED
|
@@ -44,7 +44,7 @@ class Workbench {
|
|
|
44
44
|
+ `<script src="${this.baseUrl}/out/vs/code/browser/workbench/workbench.js"></script>`;
|
|
45
45
|
}
|
|
46
46
|
async renderCallback() {
|
|
47
|
-
return await download_1.fetch(`${this.baseUrl}/out/vs/code/browser/workbench/callback.html`);
|
|
47
|
+
return await (0, download_1.fetch)(`${this.baseUrl}/out/vs/code/browser/workbench/callback.html`);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
function valueOrFirst(value) {
|
|
@@ -52,16 +52,18 @@ function valueOrFirst(value) {
|
|
|
52
52
|
}
|
|
53
53
|
async function getWorkbenchOptions(ctx, config) {
|
|
54
54
|
const options = {};
|
|
55
|
-
if (config.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
if (config.extensionPaths) {
|
|
56
|
+
await Promise.all(config.extensionPaths.map(async (extensionPath, index) => {
|
|
57
|
+
options.additionalBuiltinExtensions = await (0, extensions_1.scanForExtensions)(extensionPath, {
|
|
58
|
+
scheme: ctx.protocol,
|
|
59
|
+
authority: ctx.host,
|
|
60
|
+
path: `/static/extensions/${index}`,
|
|
61
|
+
});
|
|
62
|
+
}));
|
|
61
63
|
}
|
|
62
64
|
if (config.extensionDevelopmentPath) {
|
|
63
65
|
const developmentOptions = options.developmentOptions = {};
|
|
64
|
-
developmentOptions.extensions = await extensions_1.scanForExtensions(config.extensionDevelopmentPath, { scheme: ctx.protocol, authority: ctx.host, path: '/static/devextensions' });
|
|
66
|
+
developmentOptions.extensions = await (0, extensions_1.scanForExtensions)(config.extensionDevelopmentPath, { scheme: ctx.protocol, authority: ctx.host, path: '/static/devextensions' });
|
|
65
67
|
if (config.extensionTestsPath) {
|
|
66
68
|
let relativePath = path.relative(config.extensionDevelopmentPath, config.extensionTestsPath);
|
|
67
69
|
if (process.platform === 'win32') {
|
|
@@ -74,14 +76,15 @@ async function getWorkbenchOptions(ctx, config) {
|
|
|
74
76
|
};
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
|
-
if (config.folderUri) {
|
|
78
|
-
options.folderUri = vscode_uri_1.URI.parse(config.folderUri);
|
|
79
|
-
}
|
|
80
79
|
if (config.folderMountPath) {
|
|
81
80
|
if (!options.additionalBuiltinExtensions) {
|
|
82
81
|
options.additionalBuiltinExtensions = [];
|
|
83
82
|
}
|
|
84
83
|
options.additionalBuiltinExtensions.push({ scheme: ctx.protocol, authority: ctx.host, path: mounts_1.fsProviderExtensionPrefix });
|
|
84
|
+
options.folderUri = vscode_uri_1.URI.parse(mounts_1.fsProviderFolderUri);
|
|
85
|
+
}
|
|
86
|
+
else if (config.folderUri) {
|
|
87
|
+
options.folderUri = vscode_uri_1.URI.parse(config.folderUri);
|
|
85
88
|
}
|
|
86
89
|
return options;
|
|
87
90
|
}
|
|
@@ -90,7 +93,7 @@ function default_1(config) {
|
|
|
90
93
|
router.use(async (ctx, next) => {
|
|
91
94
|
if (ctx.query['dev'] || config.build.type === 'sources') {
|
|
92
95
|
try {
|
|
93
|
-
const builtInExtensions = await download_1.fetchJSON('http://localhost:8080/builtin');
|
|
96
|
+
const builtInExtensions = await (0, download_1.fetchJSON)('http://localhost:8080/builtin');
|
|
94
97
|
ctx.state.workbench = new Workbench('http://localhost:8080/static', true, builtInExtensions);
|
|
95
98
|
}
|
|
96
99
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vscode/test-web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"scripts": {
|
|
5
|
-
"
|
|
5
|
+
"install-extensions": "yarn --cwd=fs-provider && yarn --cwd=sample",
|
|
6
6
|
"compile": "tsc -p ./ && yarn compile-fs-provider",
|
|
7
7
|
"watch": "tsc -w -p ./",
|
|
8
8
|
"prepublishOnly": "yarn compile",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"node": ">=8.9.3"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@koa/router": "^10.
|
|
25
|
+
"@koa/router": "^10.1.1",
|
|
26
26
|
"koa": "^2.13.1",
|
|
27
27
|
"koa-morgan": "^1.0.1",
|
|
28
28
|
"koa-mount": "^4.0.0",
|
|
29
29
|
"koa-static": "^5.0.0",
|
|
30
30
|
"minimist": "^1.2.5",
|
|
31
|
-
"playwright": "
|
|
31
|
+
"playwright": "1.14.1",
|
|
32
32
|
"vscode-uri": "^3.0.2",
|
|
33
33
|
"http-proxy-agent": "^4.0.1",
|
|
34
34
|
"https-proxy-agent": "^5.0.0",
|
|
@@ -36,19 +36,19 @@
|
|
|
36
36
|
"decompress-targz": "^4.1.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@types/koa": "^2.13.
|
|
40
|
-
"@types/koa-morgan": "^1.0.
|
|
41
|
-
"@types/koa-mount": "^4.0.
|
|
42
|
-
"@types/koa-static": "^4.0.
|
|
43
|
-
"@types/koa__router": "^8.0.
|
|
44
|
-
"@types/minimist": "^1.2.
|
|
39
|
+
"@types/koa": "^2.13.4",
|
|
40
|
+
"@types/koa-morgan": "^1.0.5",
|
|
41
|
+
"@types/koa-mount": "^4.0.1",
|
|
42
|
+
"@types/koa-static": "^4.0.2",
|
|
43
|
+
"@types/koa__router": "^8.0.8",
|
|
44
|
+
"@types/minimist": "^1.2.2",
|
|
45
45
|
"@types/node": "^12.19.9",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
47
|
-
"@typescript-eslint/parser": "^4.
|
|
48
|
-
"@types/decompress": "^4.2.
|
|
49
|
-
"eslint": "^7.
|
|
50
|
-
"eslint-plugin-header": "^3.1.
|
|
51
|
-
"typescript": "^4.
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^4.31.1",
|
|
47
|
+
"@typescript-eslint/parser": "^4.31.1",
|
|
48
|
+
"@types/decompress": "^4.2.4",
|
|
49
|
+
"eslint": "^7.32.0",
|
|
50
|
+
"eslint-plugin-header": "^3.1.1",
|
|
51
|
+
"typescript": "^4.4.3"
|
|
52
52
|
},
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"author": "Visual Studio Code Team",
|