-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Generate yarn cache with THEIA_VERSION. Generate resolutions to use strict Theia dependencies #10164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate yarn cache with THEIA_VERSION. Generate resolutions to use strict Theia dependencies #10164
Changes from all commits
09b2661
8fa0785
82ccb98
8bf8337
e46c270
db0cb63
852b923
2621d56
03a03b1
6ed18ec
a4df065
9e1cd84
462c5f8
2abf55b
55c0070
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
|
Contributor
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. what is doing this file ? (in comparison with npmjs where some extensions are deployed ? )
Contributor
Author
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 file with list default extensions
Contributor
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. my question is: what's the difference with https://github.com/eclipse/che/blob/db0cb63926b0110e05d4ba6d78912f1f4d856f95/dockerfiles/theia/src/package.json#L14 ?
Contributor
Author
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. I didn't saw this changes, I will check it. add-extension.js use extensions.js script to get default extensions from github or volume, build these extensions and rebuild theia with them. Do you propose doesn't support this stuff?
Contributor
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. I was suggesting as higlighted by @sunix that if extension is stored on npmjs then we can use npmjs way of grabbing extension.
Contributor
Author
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. @benoitf I checked factory extension works with this pr too. I think, if we have released extension we can apply it to the package.json, like it was done by sunix. But in case if we have github link or volume to the source code we can use add-extensions.js script to development purpose. add-extensions.js contains optimization to reuse Theia node_modules. @benoitf What do you think? Like variant I can apply empty extensions.json, like sample. And we will apply machine-extension and che-theia-hosted-plugin-manager-extension later after release on the npm.
Contributor
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. @AndrienkoAleksandr yes it's nice to keep extensibility with this file but if possible use package.json for released artifacts on npmjs |
||
| "extensions": [ | ||
| { | ||
| "name": "theia-machines-extension", | ||
| "source": "https://github.com/eclipse/che-theia-machines-plugin.git", | ||
| "checkoutTo": "master", | ||
| "type": "git" | ||
| }, | ||
| { | ||
| "name": "@eclipse-che/che-theia-hosted-plugin-manager-extension", | ||
| "source": "https://github.com/eclipse/che-theia-hosted-plugin-manager-extension.git", | ||
| "checkoutTo": "latest-deps", | ||
| "type": "git" | ||
| } | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| "use strict"; | ||
| /* | ||
| * Copyright (c) 2018 Red Hat, Inc. | ||
| * All rights reserved. This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License v1.0 | ||
| * which accompanies this distribution, and is available at | ||
| * http://www.eclipse.org/legal/epl-v10.html | ||
| * | ||
| * Contributors: | ||
| * Red Hat, Inc. - initial API and implementation | ||
| */ | ||
| const fs = require("fs"); | ||
| const spawnSync = require("child_process").spawnSync; | ||
|
|
||
| const PACKAGE_JSON_PATH = process.argv[2]; | ||
| console.log(`Generate resolutions for ${PACKAGE_JSON_PATH}`); | ||
|
|
||
| const PACKAGE_JSON = require(PACKAGE_JSON_PATH); | ||
| const THEIA_VERSION = process.env.THEIA_VERSION; | ||
| const HOME = process.env.HOME; | ||
|
|
||
| const NPM_API_URL = 'https://api.npms.io/v2'; | ||
| const keyWords = 'keywords:theia-extension'; | ||
| const resultSize = 200; | ||
|
|
||
| const SEARCH_JSON_PATH = `${HOME}/search.json`; | ||
|
|
||
| try { | ||
| spawnSync('curl',[`${NPM_API_URL}/search?q=${keyWords}&size=${resultSize}`, '-o', SEARCH_JSON_PATH]); | ||
| } catch(error) { | ||
| console.error("Failed to get Theia depedencies. Cause: ", error); | ||
| process.exit(2); | ||
| } | ||
|
|
||
| const packageScopeRegexp = '^@theia/.*$'; | ||
| let theiaResolutionsList = []; | ||
| try { | ||
| const filteredDepList = spawnSync('jq', ['-c', `.results | map(.package) | map(.name|select(test("${packageScopeRegexp}")))`, SEARCH_JSON_PATH]); | ||
| theiaResolutionsList = JSON.parse(filteredDepList.stdout); | ||
| } catch(error) { | ||
| console.error("Failed to filter Theia resolutions. Cause: ", error); | ||
| process.exit(2); | ||
| } | ||
|
|
||
| const depResolutions = listToResolutions(theiaResolutionsList); | ||
| console.log(depResolutions); | ||
|
|
||
| PACKAGE_JSON["resolutions"] = depResolutions; | ||
| console.log(`Write generated resolutions to the package.json ${PACKAGE_JSON_PATH}`); | ||
| writeJsonToFile(PACKAGE_JSON_PATH, PACKAGE_JSON); | ||
|
|
||
| function resolutionExist(resolutionName) { | ||
| try { | ||
| console.log(`Check depedency ${resolutionName}`); | ||
| const info = spawnSync('npm', ['view', `${resolutionName}@${THEIA_VERSION}`, 'version']); | ||
| if (info.stdout.toString()) { | ||
| return true; | ||
| } | ||
| } catch(error) { | ||
| console.log(`Unable to check resolution with name ${resolutionName}`); | ||
| process.exit(3); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * Convert resolutions list to resolutions object with required THEIA_VERSION. | ||
| * | ||
| * @param resolutionsList - resolutions list. | ||
| */ | ||
| function listToResolutions(resolutionsList) { | ||
| const RESOLUTIONS = {}; | ||
|
|
||
| for (const resolution of resolutionsList) { | ||
| if (resolutionExist(resolution)) { | ||
| RESOLUTIONS[resolution] = THEIA_VERSION; | ||
| } | ||
| } | ||
|
|
||
| return RESOLUTIONS; | ||
| } | ||
|
|
||
| /** | ||
| * Write json to the file by path. | ||
| * | ||
| * @param filePath - file system location of the file. | ||
| * @param json - json object to write. | ||
| */ | ||
| function writeJsonToFile(filePath, json) { | ||
| const content = JSON.stringify(json, undefined, 4); | ||
| fs.writeFileSync(filePath, content, 'utf8'); | ||
| } |
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.
I think given version in the example won't work because plugin model is released in
0.3.12. Please add note and correct example.