@theia/cli 1.34.2 → 1.34.3
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/LICENSE +641 -641
- package/README.md +360 -360
- package/bin/theia +2 -2
- package/lib/check-dependencies.d.ts +11 -11
- package/lib/check-dependencies.js +251 -251
- package/lib/download-plugins.d.ts +38 -38
- package/lib/download-plugins.js +282 -282
- package/lib/run-test.d.ts +11 -11
- package/lib/run-test.js +56 -56
- package/lib/test-page.d.ts +17 -17
- package/lib/test-page.js +102 -102
- package/lib/theia.d.ts +1 -1
- package/lib/theia.js +530 -530
- package/package.json +8 -8
- package/src/check-dependencies.ts +310 -310
- package/src/download-plugins.ts +371 -371
- package/src/run-test.ts +67 -67
- package/src/test-page.ts +137 -137
- package/src/theia.ts +616 -616
package/lib/run-test.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2020 TypeFox and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
const puppeteer = require("puppeteer");
|
|
19
|
-
const test_page_1 = require("./test-page");
|
|
20
|
-
async function runTest(options) {
|
|
21
|
-
const { start, launch } = options;
|
|
22
|
-
const exit = !(launch && launch.devtools);
|
|
23
|
-
const testPage = await (0, test_page_1.default)({
|
|
24
|
-
files: options.files,
|
|
25
|
-
matchAppUrl: () => true,
|
|
26
|
-
newPage: async () => {
|
|
27
|
-
const browser = await puppeteer.launch(launch);
|
|
28
|
-
return browser.newPage();
|
|
29
|
-
},
|
|
30
|
-
onWillRun: async () => {
|
|
31
|
-
if (options.coverage) {
|
|
32
|
-
await Promise.all([
|
|
33
|
-
testPage.coverage.startJSCoverage(),
|
|
34
|
-
testPage.coverage.startCSSCoverage()
|
|
35
|
-
]);
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
onDidRun: async (failures) => {
|
|
39
|
-
if (options.coverage) {
|
|
40
|
-
console.log('collecting test coverage...');
|
|
41
|
-
const [jsCoverage, cssCoverage] = await Promise.all([
|
|
42
|
-
testPage.coverage.stopJSCoverage(),
|
|
43
|
-
testPage.coverage.stopCSSCoverage(),
|
|
44
|
-
]);
|
|
45
|
-
require('puppeteer-to-istanbul').write([...jsCoverage, ...cssCoverage]);
|
|
46
|
-
}
|
|
47
|
-
if (exit) {
|
|
48
|
-
await testPage.close();
|
|
49
|
-
process.exit(failures > 0 ? 1 : 0);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
const server = await start();
|
|
54
|
-
await testPage.goto(`http://${server.address}:${server.port}`);
|
|
55
|
-
}
|
|
56
|
-
exports.default = runTest;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2020 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const puppeteer = require("puppeteer");
|
|
19
|
+
const test_page_1 = require("./test-page");
|
|
20
|
+
async function runTest(options) {
|
|
21
|
+
const { start, launch } = options;
|
|
22
|
+
const exit = !(launch && launch.devtools);
|
|
23
|
+
const testPage = await (0, test_page_1.default)({
|
|
24
|
+
files: options.files,
|
|
25
|
+
matchAppUrl: () => true,
|
|
26
|
+
newPage: async () => {
|
|
27
|
+
const browser = await puppeteer.launch(launch);
|
|
28
|
+
return browser.newPage();
|
|
29
|
+
},
|
|
30
|
+
onWillRun: async () => {
|
|
31
|
+
if (options.coverage) {
|
|
32
|
+
await Promise.all([
|
|
33
|
+
testPage.coverage.startJSCoverage(),
|
|
34
|
+
testPage.coverage.startCSSCoverage()
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
onDidRun: async (failures) => {
|
|
39
|
+
if (options.coverage) {
|
|
40
|
+
console.log('collecting test coverage...');
|
|
41
|
+
const [jsCoverage, cssCoverage] = await Promise.all([
|
|
42
|
+
testPage.coverage.stopJSCoverage(),
|
|
43
|
+
testPage.coverage.stopCSSCoverage(),
|
|
44
|
+
]);
|
|
45
|
+
require('puppeteer-to-istanbul').write([...jsCoverage, ...cssCoverage]);
|
|
46
|
+
}
|
|
47
|
+
if (exit) {
|
|
48
|
+
await testPage.close();
|
|
49
|
+
process.exit(failures > 0 ? 1 : 0);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const server = await start();
|
|
54
|
+
await testPage.goto(`http://${server.address}:${server.port}`);
|
|
55
|
+
}
|
|
56
|
+
exports.default = runTest;
|
|
57
57
|
//# sourceMappingURL=run-test.js.map
|
package/lib/test-page.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import * as puppeteer from 'puppeteer';
|
|
2
|
-
export interface TestFileOptions {
|
|
3
|
-
ignore: string[];
|
|
4
|
-
extension: string[];
|
|
5
|
-
file: string[];
|
|
6
|
-
recursive: boolean;
|
|
7
|
-
sort: boolean;
|
|
8
|
-
spec: string[];
|
|
9
|
-
}
|
|
10
|
-
export interface TestPageOptions {
|
|
11
|
-
files?: Partial<TestFileOptions>;
|
|
12
|
-
newPage: () => Promise<puppeteer.Page>;
|
|
13
|
-
matchAppUrl?: (url: string) => boolean;
|
|
14
|
-
onWillRun?: () => Promise<void>;
|
|
15
|
-
onDidRun?: (failures: number) => Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
export default function newTestPage(options: TestPageOptions): Promise<puppeteer.Page>;
|
|
1
|
+
import * as puppeteer from 'puppeteer';
|
|
2
|
+
export interface TestFileOptions {
|
|
3
|
+
ignore: string[];
|
|
4
|
+
extension: string[];
|
|
5
|
+
file: string[];
|
|
6
|
+
recursive: boolean;
|
|
7
|
+
sort: boolean;
|
|
8
|
+
spec: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface TestPageOptions {
|
|
11
|
+
files?: Partial<TestFileOptions>;
|
|
12
|
+
newPage: () => Promise<puppeteer.Page>;
|
|
13
|
+
matchAppUrl?: (url: string) => boolean;
|
|
14
|
+
onWillRun?: () => Promise<void>;
|
|
15
|
+
onDidRun?: (failures: number) => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export default function newTestPage(options: TestPageOptions): Promise<puppeteer.Page>;
|
|
18
18
|
//# sourceMappingURL=test-page.d.ts.map
|
package/lib/test-page.js
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2020 TypeFox and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
const collectFiles = require('mocha/lib/cli/collect-files');
|
|
19
|
-
async function newTestPage(options) {
|
|
20
|
-
const { newPage, matchAppUrl, onWillRun, onDidRun } = options;
|
|
21
|
-
const fileOptions = {
|
|
22
|
-
ignore: options.files && options.files.ignore || [],
|
|
23
|
-
extension: options.files && options.files.extension || [],
|
|
24
|
-
file: options.files && options.files.file || [],
|
|
25
|
-
spec: options.files && options.files.spec || [],
|
|
26
|
-
recursive: options.files && options.files.recursive || false,
|
|
27
|
-
sort: options.files && options.files.sort || false
|
|
28
|
-
};
|
|
29
|
-
// quick check whether test files exist
|
|
30
|
-
const files = collectFiles(fileOptions);
|
|
31
|
-
const page = await newPage();
|
|
32
|
-
page.on('dialog', dialog => dialog.dismiss());
|
|
33
|
-
page.on('pageerror', console.error);
|
|
34
|
-
let theiaLoaded = false;
|
|
35
|
-
page.exposeFunction('fireDidUnloadTheia', () => theiaLoaded = false);
|
|
36
|
-
const preLoad = (frame) => {
|
|
37
|
-
const frameUrl = frame.url();
|
|
38
|
-
if (matchAppUrl && !matchAppUrl(frameUrl)) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (theiaLoaded) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
console.log('loading chai...');
|
|
45
|
-
theiaLoaded = true;
|
|
46
|
-
page.addScriptTag({ path: require.resolve('chai/chai.js') });
|
|
47
|
-
page.evaluate(() => window.addEventListener('beforeunload', () => window['fireDidUnloadTheia']()));
|
|
48
|
-
};
|
|
49
|
-
page.on('frameattached', preLoad);
|
|
50
|
-
page.on('framenavigated', preLoad);
|
|
51
|
-
page.on('load', async () => {
|
|
52
|
-
if (matchAppUrl && !matchAppUrl(page.url())) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
console.log('loading mocha...');
|
|
56
|
-
// replace console.log by theia logger for mocha
|
|
57
|
-
await page.waitForFunction(() => { var _a, _b; return !!((_b = (_a = window['theia']) === null || _a === void 0 ? void 0 : _a['@theia/core/lib/common/logger']) === null || _b === void 0 ? void 0 : _b.logger); }, {
|
|
58
|
-
timeout: 30 * 1000
|
|
59
|
-
});
|
|
60
|
-
await page.addScriptTag({ path: require.resolve('mocha/mocha.js') });
|
|
61
|
-
await page.waitForFunction(() => !!window['chai'] && !!window['mocha'] && !!window['theia'].container, { timeout: 30 * 1000 });
|
|
62
|
-
console.log('loading Theia...');
|
|
63
|
-
await page.evaluate(() => {
|
|
64
|
-
const { FrontendApplicationStateService } = window['theia']['@theia/core/lib/browser/frontend-application-state'];
|
|
65
|
-
const { PreferenceService } = window['theia']['@theia/core/lib/browser/preferences/preference-service'];
|
|
66
|
-
const { WorkspaceService } = window['theia']['@theia/workspace/lib/browser/workspace-service'];
|
|
67
|
-
const container = window['theia'].container;
|
|
68
|
-
const frontendApplicationState = container.get(FrontendApplicationStateService);
|
|
69
|
-
const preferenceService = container.get(PreferenceService);
|
|
70
|
-
const workspaceService = container.get(WorkspaceService);
|
|
71
|
-
return Promise.all([
|
|
72
|
-
frontendApplicationState.reachedState('ready'),
|
|
73
|
-
preferenceService.ready,
|
|
74
|
-
workspaceService.roots
|
|
75
|
-
]);
|
|
76
|
-
});
|
|
77
|
-
console.log('loading test files...');
|
|
78
|
-
await page.evaluate(() => {
|
|
79
|
-
// replace require to load modules from theia namespace
|
|
80
|
-
window['require'] = (moduleName) => window['theia'][moduleName];
|
|
81
|
-
mocha.setup({
|
|
82
|
-
reporter: 'spec',
|
|
83
|
-
ui: 'bdd',
|
|
84
|
-
color: true,
|
|
85
|
-
retries: 5
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
if (onWillRun) {
|
|
89
|
-
await onWillRun();
|
|
90
|
-
}
|
|
91
|
-
for (const file of files) {
|
|
92
|
-
await page.addScriptTag({ path: file });
|
|
93
|
-
}
|
|
94
|
-
console.log('running test files...');
|
|
95
|
-
const failures = await page.evaluate(() => new Promise(resolve => mocha.run(resolve)));
|
|
96
|
-
if (onDidRun) {
|
|
97
|
-
await onDidRun(failures);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
return page;
|
|
101
|
-
}
|
|
102
|
-
exports.default = newTestPage;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2020 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const collectFiles = require('mocha/lib/cli/collect-files');
|
|
19
|
+
async function newTestPage(options) {
|
|
20
|
+
const { newPage, matchAppUrl, onWillRun, onDidRun } = options;
|
|
21
|
+
const fileOptions = {
|
|
22
|
+
ignore: options.files && options.files.ignore || [],
|
|
23
|
+
extension: options.files && options.files.extension || [],
|
|
24
|
+
file: options.files && options.files.file || [],
|
|
25
|
+
spec: options.files && options.files.spec || [],
|
|
26
|
+
recursive: options.files && options.files.recursive || false,
|
|
27
|
+
sort: options.files && options.files.sort || false
|
|
28
|
+
};
|
|
29
|
+
// quick check whether test files exist
|
|
30
|
+
const files = collectFiles(fileOptions);
|
|
31
|
+
const page = await newPage();
|
|
32
|
+
page.on('dialog', dialog => dialog.dismiss());
|
|
33
|
+
page.on('pageerror', console.error);
|
|
34
|
+
let theiaLoaded = false;
|
|
35
|
+
page.exposeFunction('fireDidUnloadTheia', () => theiaLoaded = false);
|
|
36
|
+
const preLoad = (frame) => {
|
|
37
|
+
const frameUrl = frame.url();
|
|
38
|
+
if (matchAppUrl && !matchAppUrl(frameUrl)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (theiaLoaded) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
console.log('loading chai...');
|
|
45
|
+
theiaLoaded = true;
|
|
46
|
+
page.addScriptTag({ path: require.resolve('chai/chai.js') });
|
|
47
|
+
page.evaluate(() => window.addEventListener('beforeunload', () => window['fireDidUnloadTheia']()));
|
|
48
|
+
};
|
|
49
|
+
page.on('frameattached', preLoad);
|
|
50
|
+
page.on('framenavigated', preLoad);
|
|
51
|
+
page.on('load', async () => {
|
|
52
|
+
if (matchAppUrl && !matchAppUrl(page.url())) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
console.log('loading mocha...');
|
|
56
|
+
// replace console.log by theia logger for mocha
|
|
57
|
+
await page.waitForFunction(() => { var _a, _b; return !!((_b = (_a = window['theia']) === null || _a === void 0 ? void 0 : _a['@theia/core/lib/common/logger']) === null || _b === void 0 ? void 0 : _b.logger); }, {
|
|
58
|
+
timeout: 30 * 1000
|
|
59
|
+
});
|
|
60
|
+
await page.addScriptTag({ path: require.resolve('mocha/mocha.js') });
|
|
61
|
+
await page.waitForFunction(() => !!window['chai'] && !!window['mocha'] && !!window['theia'].container, { timeout: 30 * 1000 });
|
|
62
|
+
console.log('loading Theia...');
|
|
63
|
+
await page.evaluate(() => {
|
|
64
|
+
const { FrontendApplicationStateService } = window['theia']['@theia/core/lib/browser/frontend-application-state'];
|
|
65
|
+
const { PreferenceService } = window['theia']['@theia/core/lib/browser/preferences/preference-service'];
|
|
66
|
+
const { WorkspaceService } = window['theia']['@theia/workspace/lib/browser/workspace-service'];
|
|
67
|
+
const container = window['theia'].container;
|
|
68
|
+
const frontendApplicationState = container.get(FrontendApplicationStateService);
|
|
69
|
+
const preferenceService = container.get(PreferenceService);
|
|
70
|
+
const workspaceService = container.get(WorkspaceService);
|
|
71
|
+
return Promise.all([
|
|
72
|
+
frontendApplicationState.reachedState('ready'),
|
|
73
|
+
preferenceService.ready,
|
|
74
|
+
workspaceService.roots
|
|
75
|
+
]);
|
|
76
|
+
});
|
|
77
|
+
console.log('loading test files...');
|
|
78
|
+
await page.evaluate(() => {
|
|
79
|
+
// replace require to load modules from theia namespace
|
|
80
|
+
window['require'] = (moduleName) => window['theia'][moduleName];
|
|
81
|
+
mocha.setup({
|
|
82
|
+
reporter: 'spec',
|
|
83
|
+
ui: 'bdd',
|
|
84
|
+
color: true,
|
|
85
|
+
retries: 5
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
if (onWillRun) {
|
|
89
|
+
await onWillRun();
|
|
90
|
+
}
|
|
91
|
+
for (const file of files) {
|
|
92
|
+
await page.addScriptTag({ path: file });
|
|
93
|
+
}
|
|
94
|
+
console.log('running test files...');
|
|
95
|
+
const failures = await page.evaluate(() => new Promise(resolve => mocha.run(resolve)));
|
|
96
|
+
if (onDidRun) {
|
|
97
|
+
await onDidRun(failures);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
return page;
|
|
101
|
+
}
|
|
102
|
+
exports.default = newTestPage;
|
|
103
103
|
//# sourceMappingURL=test-page.js.map
|
package/lib/theia.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=theia.d.ts.map
|