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
feat(namespace): Export @eclipse-che/plugin namespace using VS Code extension mechanism #994
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,8 @@ | |
"@theia/plugin-packager": "latest" | ||
}, | ||
"extensionDependencies": [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I didn't get why the Workspace Plug-in has to depend on it? If it's just for bootstrapping, isn't the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's to make sure that it's loaded as first plug-ins because there is no concept of optional dependency in VScode api |
||
"Eclipse Che.@eclipse-che/theia-ssh-plugin" | ||
"Eclipse Che.@eclipse-che/theia-ssh-plugin", | ||
"@eclipse-che.ext-plugin" | ||
], | ||
"scripts": { | ||
"prepare": "yarn clean && yarn lint:fix && yarn build && yarn test", | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something more descriptive? E.g.
che-api-export-plugin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the folder can be as long as you want (can change it easily) but for the name of the plug-in it looks a bit too long/verbose for consumers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, it's important to have the name as short as possible here. I just forgot it's supposed to be used by the external VS Code extensions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you've a better short name suggestion, I can rename it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good. Nevermind )