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(recommendations): Provide a plug-in for recommendations
Devfile without plug-ins: provide featured plug-ins and ask to reload workspace With plug-ins: suggest it When opening file: Inform that some plug-ins may exist Change-Id: I5d35f5329f44504e4e6fcad3ba198aa932d50252 Signed-off-by: Florent Benoit <fbenoit@redhat.com>
- Loading branch information
Showing
63 changed files
with
11,916 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2020 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-next-line no-undef | ||
module.exports = { | ||
root: true, | ||
parser: '@typescript-eslint/parser', | ||
rules: { | ||
'@typescript-eslint/naming-convention': [ | ||
'error', | ||
{ | ||
selector: 'variable', | ||
format: ['camelCase', 'UPPER_CASE'], | ||
}, | ||
], | ||
'@typescript-eslint/consistent-type-definitions': 'error', | ||
'@typescript-eslint/indent': 'off', | ||
'@typescript-eslint/no-explicit-any': 'error', | ||
'@typescript-eslint/quotes': [ | ||
'error', | ||
'single', | ||
{ | ||
avoidEscape: true, | ||
}, | ||
], | ||
'@typescript-eslint/semi': ['error', 'always'], | ||
'@typescript-eslint/type-annotation-spacing': 'error', | ||
'arrow-body-style': ['error', 'as-needed'], | ||
'arrow-parens': ['error', 'as-needed'], | ||
camelcase: 'off', | ||
'comma-dangle': 'off', | ||
curly: 'error', | ||
'eol-last': 'error', | ||
eqeqeq: ['error', 'smart'], | ||
'guard-for-in': 'error', | ||
'id-blacklist': 'off', | ||
'id-match': 'off', | ||
'import/no-deprecated': 'error', | ||
'import/no-extraneous-dependencies': 'off', | ||
'max-len': [ | ||
'error', | ||
{ | ||
code: 180, | ||
}, | ||
], | ||
'no-magic-numbers': 'off', | ||
'no-multiple-empty-lines': [ | ||
'error', | ||
{ | ||
max: 1, | ||
}, | ||
], | ||
'no-new-wrappers': 'error', | ||
'no-null/no-null': 'error', | ||
'no-shadow': [ | ||
'error', | ||
{ | ||
hoist: 'all', | ||
}, | ||
], | ||
'no-throw-literal': 'error', | ||
'no-trailing-spaces': 'error', | ||
'no-underscore-dangle': 'off', | ||
'no-unused-expressions': 'error', | ||
'no-var': 'error', | ||
'no-void': 'error', | ||
'one-var': ['error', 'never'], | ||
'prefer-const': [ | ||
'error', | ||
{ | ||
destructuring: 'all', | ||
}, | ||
], | ||
radix: 'off', | ||
'space-before-function-paren': [ | ||
'error', | ||
{ | ||
anonymous: 'always', | ||
named: 'never', | ||
asyncArrow: 'always', | ||
}, | ||
], | ||
'spaced-comment': [ | ||
'error', | ||
'always', | ||
{ | ||
exceptions: ['*', '+', '-', '/'], | ||
}, | ||
], | ||
'header/header': [ | ||
2, | ||
'block', | ||
[ | ||
'*********************************************************************', | ||
{ | ||
pattern: '^ \\* Copyright \\(c\\) \\d{4}(-\\d{4})* Red Hat, Inc\\.$', | ||
template: ' * Copyright (c) 2020 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', | ||
' **********************************************************************', | ||
], | ||
], | ||
}, | ||
plugins: ['header', '@typescript-eslint', 'jest', 'import', 'no-null'], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'prettier/@typescript-eslint', | ||
'plugin:jest/recommended', | ||
], | ||
}; |
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,2 @@ | ||
# recommendations-plugin | ||
recommendations-plugin providing recommendations for plug-ins to use. |
20 changes: 20 additions & 0 deletions
20
plugins/recommendations-plugin/__mocks__/@eclipse-che/plugin.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,20 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2020 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-empty-function */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
/** | ||
* Mock of @theia/plugin module | ||
* @author Florent Benoit | ||
*/ | ||
const che: any = {}; | ||
che.workspace = {}; | ||
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,28 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2020 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-empty-function */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
/** | ||
* Mock of @theia/plugin module | ||
* @author Florent Benoit | ||
*/ | ||
const theia: any = {}; | ||
theia.window = {}; | ||
theia.plugins = {}; | ||
theia.plugins.all = []; | ||
theia.window.showInformationMessage = jest.fn(); | ||
theia.workspace = { | ||
workspaceFolders: undefined, | ||
onDidOpenTextDocument: jest.fn(), | ||
}; | ||
theia.plugins.getPlugin = jest.fn(); | ||
module.exports = theia; |
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,42 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2020 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 */ | ||
|
||
const axios: any = jest.createMockFromModule('axios'); | ||
|
||
// map between URL and content | ||
const myContent: Map<string, any> = new Map(); | ||
const myErrors: Map<string, any> = new Map(); | ||
|
||
function __setContent(url: string, content: string): void { | ||
myContent.set(url, content); | ||
} | ||
|
||
function __setError(url: string, error: any): void { | ||
myErrors.set(url, error); | ||
} | ||
|
||
function get(url: string): any { | ||
if (myErrors.has(url)) { | ||
throw myErrors.get(url); | ||
} | ||
|
||
return Promise.resolve({ data: myContent.get(url) }); | ||
} | ||
function __clearMock(): void { | ||
myContent.clear(); | ||
myErrors.clear(); | ||
} | ||
|
||
axios.get = jest.fn(get); | ||
axios.__setContent = __setContent; | ||
axios.__setError = __setError; | ||
axios.__clearMock = __clearMock; | ||
module.exports = axios; |
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,41 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2020 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 */ | ||
|
||
const globby: any = jest.requireActual('globby'); | ||
|
||
let customError: any | undefined = undefined; | ||
let multipleEnd = false; | ||
|
||
function __setStreamError(error: string): void { | ||
customError = error; | ||
} | ||
|
||
function __setStreamEnd(): void { | ||
multipleEnd = true; | ||
} | ||
|
||
globby.__setStreamError = __setStreamError; | ||
globby.__setStreamEnd = __setStreamEnd; | ||
|
||
const originalStream = globby.stream; | ||
globby.stream = (pattern: any, options?: any) => { | ||
const result = originalStream(pattern, options); | ||
if (customError) { | ||
result.emit('error', customError); | ||
} | ||
if (multipleEnd) { | ||
result.emit('end'); | ||
} | ||
return result; | ||
}; | ||
|
||
module.exports = globby; |
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,92 @@ | ||
{ | ||
"name": "recommendation-plugin", | ||
"publisher": "Eclipse-Che", | ||
"keywords": [ | ||
"theia-plugin" | ||
], | ||
"version": "0.0.1", | ||
"license": "EPL-2.0", | ||
"files": [ | ||
"src" | ||
], | ||
"dependencies": { | ||
"@eclipse-che/plugin": "0.0.1", | ||
"@theia/plugin": "next", | ||
"axios": "^0.21.0", | ||
"globby": "^11.0.1", | ||
"inversify": "^5.0.1", | ||
"kind-of": "^6.0.3", | ||
"reflect-metadata": "^0.1.13" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^26", | ||
"@theia/plugin-packager": "latest", | ||
"@types/fs-extra": "^9.0.3", | ||
"eslint-plugin-header": "^3.1.0", | ||
"ts-jest": "26.4.3", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.1.2", | ||
"prettier-plugin-import-sort": "^0.0.6" | ||
}, | ||
"activationEvents": [ | ||
"*" | ||
], | ||
"scripts": { | ||
"prepare": "yarn run clean && yarn run build", | ||
"clean": "rimraf lib", | ||
"watch": "tsc -watch", | ||
"compile": "tsc", | ||
"format": "prettier --write .eslintrc.js **/*.ts **/**/*.ts package.json", | ||
"format-check": "prettier --check .eslintrc.js **/*.ts **/**/*.ts package.json", | ||
"lint": "eslint . --ext .ts", | ||
"build": "yarn run format-check && yarn run compile && yarn run lint && yarn run test && theia-plugin pack", | ||
"test": "jest --forceExit", | ||
"test-watch": "jest --watchAll" | ||
}, | ||
"engines": { | ||
"theiaPlugin": "next" | ||
}, | ||
"theiaPlugin": { | ||
"backend": "lib/plugin.js" | ||
}, | ||
"jest": { | ||
"collectCoverage": true, | ||
"collectCoverageFrom": [ | ||
"src/**/*.ts" | ||
], | ||
"coverageThreshold": { | ||
"global": { | ||
"branches": 100, | ||
"functions": 100, | ||
"lines": 100, | ||
"statements": 100 | ||
} | ||
}, | ||
"coverageDirectory": "./coverage", | ||
"transform": { | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
"modulePathIgnorePatterns": [ | ||
"<rootDir>/lib" | ||
], | ||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"jsx", | ||
"json" | ||
] | ||
}, | ||
"prettier": { | ||
"printWidth": 120, | ||
"singleQuote": true, | ||
"arrowParens": "avoid" | ||
}, | ||
"importSort": { | ||
".ts": { | ||
"style": "eslint", | ||
"parser": "typescript" | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
plugins/recommendations-plugin/src/analyzer/analyzer-module.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,18 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2020 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 { ContainerModule, interfaces } from 'inversify'; | ||
|
||
import { VSCodeCurrentPlugins } from './vscode-current-plugins'; | ||
|
||
const analyzerModule = new ContainerModule((bind: interfaces.Bind) => { | ||
bind(VSCodeCurrentPlugins).toSelf().inSingletonScope(); | ||
}); | ||
|
||
export { analyzerModule }; |
15 changes: 15 additions & 0 deletions
15
plugins/recommendations-plugin/src/analyzer/language-information.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,15 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2020 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 | ||
***********************************************************************/ | ||
export interface LanguageInformation { | ||
id: string; | ||
fileExtensions: string[]; | ||
extensions: string[]; | ||
workspaceContains: string[]; | ||
} |
Oops, something went wrong.