This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(namespace): Export @eclipse-che/plugin namespace using VS Code e…
…xtension mechanism Change-Id: I4d8d6c49b6797bd98b76486127ec3e38f243e120 Signed-off-by: Florent Benoit <fbenoit@redhat.com>
- Loading branch information
Showing
9 changed files
with
174 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
lib/ | ||
node_modules/ | ||
*.theia | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Ext Plug-in | ||
This plug-in is exposing some Eclipse Che API to be consumed by other VS Code extensions using the VS Code extension mechanism. | ||
|
||
## Example | ||
|
||
```typescript | ||
const eclipseCheExtPlugin = vscode.extensions.getExtension('@eclipse-che.ext-plugin'); | ||
if (eclipseCheExtPlugin) { | ||
// grab user | ||
const user = await eclipseCheExtPlugin.exports.user.getCurrentUser(); | ||
vscode.window.showInformationMessage(`Eclipse Che user information: id ${user.id} with name ${user.name}`); | ||
} | ||
``` | ||
|
||
Exported code is coming from https://github.com/eclipse/che-theia/blob/master/extensions/eclipse-che-theia-plugin/src/che-proposed.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2021 Red Hat, Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
***********************************************************************/ | ||
|
||
/** | ||
* Mock of @eclipse-che/plugin module | ||
* @author Florent Benoit | ||
*/ | ||
const che: any = {}; | ||
let currentWorkspace: any = undefined; | ||
|
||
che.setWorkspaceOutput = (input: any) => { | ||
currentWorkspace = input; | ||
}; | ||
|
||
che.workspace = {}; | ||
|
||
che.workspace.getCurrentWorkspace = () => { | ||
return currentWorkspace; | ||
}; | ||
|
||
module.exports = che; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"name": "ext-plugin", | ||
"publisher": "@eclipse-che", | ||
"version": "0.0.1", | ||
"keywords": [ | ||
"theia-plugin" | ||
], | ||
"description": "Exports @eclipse-che/plugin namespace", | ||
"license": "EPL-2.0", | ||
"files": [ | ||
"src" | ||
], | ||
"activationEvents": [ | ||
"*" | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@eclipse-che/plugin": "latest", | ||
"@theia/plugin": "next", | ||
"@theia/plugin-packager": "latest" | ||
}, | ||
"scripts": { | ||
"prepare": "yarn clean && yarn build && yarn lint:fix && yarn test", | ||
"clean": "rimraf lib", | ||
"format": "if-env SKIP_FORMAT=true && echo 'skip format check' || prettier --check '{src,tests}/**/*.ts' package.json", | ||
"format:fix": "prettier --write '{src,tests}/**/*.ts' package.json", | ||
"lint": "if-env SKIP_LINT=true && echo 'skip lint check' || eslint --cache=true --no-error-on-unmatched-pattern=true '{src,tests}/**/*.ts'", | ||
"lint:fix": "eslint --fix --cache=true --no-error-on-unmatched-pattern=true \"{src,tests}/**/*.{ts,tsx}\"", | ||
"compile": "tsc", | ||
"build": "concurrently -n \"format,lint,compile\" -c \"red,green,blue\" \"yarn format\" \"yarn lint\" \"yarn compile\" && theia-plugin pack", | ||
"watch": "tsc -w", | ||
"test": "if-env SKIP_TEST=true && echo 'skip test' || jest --forceExit", | ||
"test-watch": "jest --watchAll" | ||
}, | ||
"engines": { | ||
"theiaPlugin": "next" | ||
}, | ||
"theiaPlugin": { | ||
"backend": "lib/ext-plugin.js" | ||
}, | ||
"jest": { | ||
"collectCoverage": true, | ||
"collectCoverageFrom": [ | ||
"src/**/*.ts" | ||
], | ||
"coverageDirectory": "./coverage", | ||
"transform": { | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
"modulePathIgnorePatterns": [ | ||
"<rootDir>/dist" | ||
], | ||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"jsx", | ||
"json" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2021 Red Hat, Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
***********************************************************************/ | ||
|
||
import * as che from '@eclipse-che/plugin'; | ||
/** | ||
* Export @eclipse-che/plugin namespace as extensions.getExtension('@eclipse-che/ext-plugin') value | ||
*/ | ||
export async function start(): Promise<unknown> { | ||
const apiObject = che; | ||
return apiObject; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2021 Red Hat, Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
***********************************************************************/ | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
import * as che from '@eclipse-che/plugin'; | ||
import * as extPlugin from '../src/ext-plugin'; | ||
|
||
describe('Test ExtPlugin', () => { | ||
test('start', async () => { | ||
(che as any).setWorkspaceOutput({ id: '1234' }); | ||
|
||
const api: any = await extPlugin.start(); | ||
expect(api).toBeDefined(); | ||
const workspace = await api.workspace.getCurrentWorkspace(); | ||
expect(workspace.id).toBe('1234'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "../../configs/base.tsconfig", | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": [ | ||
"es6", | ||
"webworker" | ||
], | ||
"sourceMap": true, | ||
"rootDir": "src", | ||
"outDir": "lib", | ||
"types": [ | ||
"node", "jest" | ||
] | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters