Skip to content

Commit

Permalink
WIP lalalal
Browse files Browse the repository at this point in the history
  • Loading branch information
akosyakov committed Jan 9, 2020
1 parent b445b08 commit 5a3db5f
Show file tree
Hide file tree
Showing 37 changed files with 1,018 additions and 1,667 deletions.
6 changes: 0 additions & 6 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,6 @@ vscode-java-debug (0.15.0)

* License: MIT

webdriverio (n/a)

* License: MIT
* Project: http://webdriver.io/
* Source: https://github.com/webdriverio/webdriverio.git

when (3.7.8)

* License: MIT
Expand Down
1 change: 1 addition & 0 deletions dev-packages/application-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@theia/application-package": "^0.14.0",
"@theia/compression-webpack-plugin": "^3.0.0",
"@types/fs-extra": "^4.0.2",
"@types/webpack": "^4.41.2",
"babel-loader": "^8.0.6",
"circular-dependency-plugin": "^5.0.0",
"copy-webpack-plugin": "^4.5.0",
Expand Down
66 changes: 66 additions & 0 deletions dev-packages/application-manager/src/expose-loader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/********************************************************************************
* Copyright (C) 2019 TypeFox and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import * as path from 'path';
import * as webpack from 'webpack';
import { ApplicationPackage } from '@theia/application-package/lib/application-package';

const modulePackages: { dir: string, name?: string }[] = [];
for (const extensionPackage of new ApplicationPackage({ projectPath: process.cwd() }).extensionPackages) {
modulePackages.push({
name: extensionPackage.name,
dir: path.dirname(extensionPackage.raw.installed!.packagePath)
});
}

function exposeModule(modulePackage: { dir: string, name?: string }, resourcePath: string, source: string): string {
if (!modulePackage.name) {
return source;
}
const { dir, name } = path.parse(resourcePath);
let moduleName = path.join(modulePackage.name, dir.substring(modulePackage.dir.length));
if (name !== 'index') {
moduleName = path.join(moduleName, name);
}
return source + `\nif (!global) global = {};\n(global['theia'] = global['theia'] || {})['${moduleName}'] = this;\n`;
}

export = function (this: webpack.loader.LoaderContext, source: string): string {
if (this.cacheable) {
this.cacheable();
}

let modulePackage = modulePackages.find(({ dir }) => this.resourcePath.startsWith(dir));
if (modulePackage) {
return exposeModule(modulePackage, this.resourcePath, source);
}
const index = this.resourcePath.lastIndexOf('/node_modules');
if (index !== -1) {
const nodeModulesPath = this.resourcePath.substring(0, index + '/node_modules'.length);
let dir = this.resourcePath;
while ((dir = path.dirname(dir)) !== nodeModulesPath) {
try {
const { name } = require(path.join(dir, 'package.json'));
modulePackage = { name, dir };
modulePackages.push(modulePackage);
return exposeModule(modulePackage, this.resourcePath, source);
} catch {
/** no-op */
}
}
}
return source;
};
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ function load(raw) {
}
function start() {
(window['theia'] = window['theia'] || {}).container = container;
const themeService = ThemeService.get();
themeService.loadUserTheme();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ module.exports = {
cacheDirectory: true
}
}
},
/**
* Expose bundled modules on window.theia.moduleName namespace, e.g.
* window['theia']['@theia/core/lib/common/uri'].
* Such syntax can be used by external code, for instance, for testing.
*/
{
test: /\\.js$/,
loader: require.resolve('@theia/application-manager/lib/expose-loader')
}
]
},
Expand Down
9 changes: 0 additions & 9 deletions examples/browser/compile.tsconfig.json

This file was deleted.

38 changes: 0 additions & 38 deletions examples/browser/coverage-webpack.config.js

This file was deleted.

13 changes: 6 additions & 7 deletions examples/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,17 @@
},
"scripts": {
"prepare": "yarn run clean && yarn build",
"clean": "theia clean && rimraf errorShots",
"build": "theiaext compile && theia build --mode development",
"watch": "concurrently -n compile,bundle \"theiaext watch --preserveWatchOutput\" \"theia build --watch --mode development\"",
"clean": "theia clean",
"build": "theia build --mode development",
"watch": "yarn build --watch",
"start": "theia start --plugins=local-dir:../../plugins",
"start:debug": "yarn start --log-level=debug",
"test": "wdio wdio.conf.js",
"test-non-headless": "wdio wdio-non-headless.conf.js",
"coverage:compile": "yarn build --config coverage-webpack.config.js",
"test": "node test/cli.js .",
"test:debug": "yarn test --inspect",
"coverage:remap": "remap-istanbul -i coverage/coverage.json -o coverage/coverage-final.json --exclude 'frontend/index.js' && rimraf coverage/coverage.json",
"coverage:report:html": "istanbul report --root coverage --format html",
"coverage:report:lcov": "istanbul report --root coverage --format lcov",
"coverage": "yarn coverage:compile && yarn test && yarn coverage:remap && yarn coverage:report:lcov && yarn coverage:report:html"
"coverage": "yarn test && yarn coverage:remap && yarn coverage:report:lcov && yarn coverage:report:html"
},
"devDependencies": {
"@theia/cli": "^0.14.0"
Expand Down
81 changes: 0 additions & 81 deletions examples/browser/test/bottom-panel/bottom-panel.ts

This file was deleted.

11 changes: 11 additions & 0 deletions examples/browser/test/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @ts-check
const { DEBUG_MODE } = require('@theia/core/lib/node/debug');
require('./run-test')({
launch: {
args: ['--no-sandbox'],
devtools: DEBUG_MODE
},
collectFiles: {
spec: ['test/*.spec.js']
}
});
42 changes: 42 additions & 0 deletions examples/browser/test/editors.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/********************************************************************************
* Copyright (C) 2019 TypeFox and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

// @ts-check
describe('Editors', function () {

const { assert } = chai;

const { EditorManager } = require('@theia/editor/lib/browser/editor-manager');
const Uri = require('@theia/core/lib/common/uri');
const { WorkspaceService } = require('@theia/workspace/lib/browser/workspace-service');

/** @type {import('inversify').Container} */
const container = window['theia'].container;
const editorManager = container.get(EditorManager);
const workspaceService = container.get(WorkspaceService);

before(() => editorManager.closeAll());

it('open', async () => {
const root = (await workspaceService.roots)[0];
assert.equal(editorManager.all.length, 0);
await editorManager.open(new Uri.default(root.uri).resolve('package.json'), {
mode: 'reveal'
});
assert.equal(editorManager.all.length, 1);
});

});
Loading

0 comments on commit 5a3db5f

Please sign in to comment.