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.
eclipse-che/che#13738 move che-theia generator to che-theia repository
Signed-off-by: Yevhen Vydolob <yvydolob@redhat.com>
- Loading branch information
Showing
74 changed files
with
16,564 additions
and
69 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
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,14 @@ | ||
root = true | ||
|
||
[*] | ||
insert_final_newline = true | ||
end_of_line = lf | ||
indent_style = space | ||
trim_trailing_spaces = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.{js,ts,md}] | ||
indent_size = 4 | ||
|
||
[*.{json,yml}] | ||
indent_size = 2 |
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,7 @@ | ||
node_modules | ||
dist | ||
coverage | ||
yarn-error.log | ||
.vscode | ||
exe | ||
/lib/ |
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,21 @@ | ||
# @eclipse-che/theia-generator | ||
|
||
|
||
# Contributing to this CLI | ||
|
||
This project is using yargs to manage CLI options. [See src/yargs.ts file](src/yargs.ts) | ||
|
||
## Code formatter/linter | ||
when doing `yarn` command, formatter is executed with linter, etc. | ||
|
||
## Unit tests | ||
jest is used to test the project. | ||
|
||
`yarn run test` is launching all the tests. A code coverage is also reported in `./coverage` folder. | ||
|
||
Try to expect 100% of coverage when implementing a feature (for now only yargs.ts is not covered as I haven't figured out a good way to test it, welcome !) | ||
|
||
## native executable | ||
The cli can also be generated to a native executable (run `yar run exe`) | ||
|
||
It will produce several native binaries. |
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,89 @@ | ||
# @eclipse-che/theia-generator | ||
=================================== | ||
|
||
|
||
# Installation guide | ||
|
||
Theia Generator can be installed locally or globally | ||
|
||
Here is how to install it globally: | ||
|
||
using yarn: | ||
``` | ||
$ yarn global add @eclipse-che/theia-generator | ||
``` | ||
|
||
using npm: | ||
``` | ||
$ npm install -g @eclipse-che/theia-generator | ||
``` | ||
|
||
Then, a new command line tool is available : `che:theia` | ||
|
||
# Using the tool | ||
|
||
Once the tool is installed, the following commands are available: | ||
- `che:theia init` | ||
- `che:theia production` | ||
|
||
(help is also available with command `che:theia --help`) | ||
|
||
## che:theia init | ||
|
||
This command needs to be launched inside a cloned directory of Eclipse Theia cloned directory | ||
|
||
``` | ||
$ git clone https://github.com/theia-ide/theia | ||
$ cd theia | ||
$ che:theia init | ||
``` | ||
|
||
once the init command has been launched: | ||
- inside `theia/che` folder, all extensions and plugins have been cloned and checkout to their correct branches (if specified) | ||
- all extensions have their package.json updated to the versions used by the current theia. (cloned) | ||
- in `packages` folder, there are symlinks for each extension coming from `theia/che` folders. All packages are prefixed by `@che-` | ||
- in `plugins` folder, there are symlinks for each plugin coming from `theia/che` folders. | ||
- in `examples` folder, a new folder named àssembly` has been generated and include the `che-theia` assembly of Theia | ||
|
||
In order to build the product, just run `yarn` at the root folder (where theia has been cloned) | ||
|
||
### Custom extension and plugin set | ||
|
||
Also you can provide custom `yaml` with your extension set, by using `-c` or `--config` parameter of `che:theia init` : | ||
|
||
`che:theia init -c ./path/to/custom/che-theia-init-sources.yaml` | ||
|
||
The sample of `che-theia-init-sources.yaml` can be found [there](https://github.com/eclipse/che-theia/blob/master/che-theia-init-sources.yml) | ||
|
||
### Dev mode | ||
|
||
Dev mode is the way to use all new extensions from `master` branch: | ||
|
||
`che:theia init -d` | ||
|
||
And `che:theia` will use `master` branch for all extensions and plugins, regardless of provided configuration | ||
|
||
### Development life-cycle | ||
it's easy to check changes. Running yarn watch in a module and then running yarn watch in `examples/assembly` folder and using `yarn run start` in `examples/assembly` | ||
|
||
### compiling the plugins | ||
Plugins have to be compiled separately with the script `plugins/foreach_yarn`. This script simply run the `yarn` command on each subfolders of `plugins` and copy the `.theia` package in `production/plugins` folder to be reused by the che-theia product. | ||
|
||
## che:theia production | ||
A production's ready assembly of che-theia can be obtained by running from the root folder of theia: `che:theia production` | ||
|
||
It will generate in `${where theia has been cloned}/production` folder a ready-to-use assembly of theia, without lot of files (like source maps, source code, etc) | ||
|
||
It can be started with the command `node ${where theia has been cloned}/production/src-gen/backend/main.js` | ||
|
||
## che:theia clean | ||
|
||
If you want to clean up your Theia repository use | ||
`che:theia clean` command, and it will undo all modification on your repository | ||
|
||
# Developer's guide | ||
[See Contributing](CONTRIBUTING.md) | ||
|
||
# License | ||
|
||
[EPL-2.0](LICENSE) |
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,85 @@ | ||
{ | ||
"name": "@eclipse-che/theia-generator", | ||
"version": "0.0.1", | ||
"description": "Eclipse Che - Theia tooling", | ||
"author": "Florent Benoit", | ||
"license": "EPL-2.0", | ||
"bin": { | ||
"che:theia": "./dist/index.js" | ||
}, | ||
"dependencies": { | ||
"fs-extra": "7.0.1", | ||
"glob": "7.1.3", | ||
"glob-promise": "3.4.0", | ||
"mustache": "3.0.1", | ||
"js-yaml": "3.12.0", | ||
"read-pkg": "3.0.0", | ||
"yargs": "12.0.5", | ||
"webpack": "^4.0.0", | ||
"html-webpack-plugin": "^3.2.0", | ||
"axios": "0.18.0", | ||
"tmp": "^0.0.33" | ||
}, | ||
"devDependencies": { | ||
"@types/fs-extra": "5.0.4", | ||
"@types/jest": "23.3.9", | ||
"@types/js-yaml": "3.11.2", | ||
"@types/mustache": "0.8.32", | ||
"@types/node": "10.12.10", | ||
"@types/read-pkg": "3.0.0", | ||
"@types/tmp": "^0.0.33", | ||
"@types/webpack": "^4.0.0", | ||
"@types/yargs": "12.0.1", | ||
"jest": "23.6.0", | ||
"json2yaml": "^1.1.0", | ||
"nexe": "^2.0.0-rc.34", | ||
"rimraf": "2.6.2", | ||
"ts-jest": "23.10.5", | ||
"tslint": "5.11.0", | ||
"typescript": "3.1.6", | ||
"typescript-formatter": "7.2.2" | ||
}, | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"scripts": { | ||
"prepare": "yarn run clean && yarn run build", | ||
"clean": "rimraf dist", | ||
"build": "yarn run compile && yarn run format-code && yarn run tslint-fix && yarn run test", | ||
"compile": "tsc && chmod +x dist/index.js", | ||
"watch": "tsc -w", | ||
"test": "jest", | ||
"test-watch": "jest --watchAll", | ||
"format-code": "tsfmt -r", | ||
"tslint-fix": "tslint --fix --project .", | ||
"tslint": "tslint --project .", | ||
"exe": "yarn run exe:alpine && yarn run exe:mac && yarn run exe:linux", | ||
"exe:alpine": "rimraf exe/alpine/ && mkdir -p exe/alpine && nexe dist/yargs.js -t alpine-x64-8.12.0 -o exe/alpine/che-theia", | ||
"exe:mac": "rimraf exe/macOS/ && mkdir -p exe/macOS && nexe dist/yargs.js -t mac-x64-8.12.0 -o exe/macOS/che-theia", | ||
"exe:linux": "rimraf exe/linux/ && mkdir -p exe/linux && nexe dist/yargs.js -t linux-x64-8.12.0 -o exe/linux/che-theia", | ||
"publish:next": "yarn publish --registry=https://registry.npmjs.org/ --no-git-tag-version --new-version 0.0.1-\"$(date +%s)\"" | ||
}, | ||
"jest": { | ||
"collectCoverage": true, | ||
"collectCoverageFrom": [ | ||
"!src/yargs.ts", | ||
"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,41 @@ | ||
/********************************************************************* | ||
* Copyright (c) 2018 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 | ||
**********************************************************************/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* Mock of the command class. | ||
*/ | ||
export class Command { | ||
|
||
/** | ||
* Map between the name of the exec command and the output. | ||
*/ | ||
private static readonly execMap: Map<string, string> = new Map(); | ||
|
||
// mock any exec command by providing the output | ||
public static __setExecCommandOutput(command: string, output: string): void { | ||
Command.execMap.set(command, output); | ||
} | ||
|
||
constructor() { | ||
|
||
} | ||
|
||
public async exec(command: string): Promise<string> { | ||
const result = Command.execMap.get(command); | ||
if (result) { | ||
return Promise.resolve(result); | ||
} else { | ||
return Promise.resolve(''); | ||
} | ||
} | ||
|
||
} |
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) 2018 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 | ||
**********************************************************************/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* Mock of the Yarn class. | ||
*/ | ||
export class Yarn { | ||
|
||
/** | ||
* Map between the name of the root Moduleand the output. | ||
*/ | ||
private static readonly dependenciesMap: Map<string, string[]> = new Map(); | ||
|
||
// mock any exec command by providing the output | ||
public static __setDependencies(rootModule: string, dependencies: string[]): void { | ||
Yarn.dependenciesMap.set(rootModule, dependencies); | ||
} | ||
|
||
constructor() { | ||
|
||
} | ||
|
||
public async getDependencies(rootModule: string): Promise<string[]> { | ||
const result = Yarn.dependenciesMap.get(rootModule); | ||
if (result) { | ||
return Promise.resolve(result); | ||
} else { | ||
return Promise.resolve([]); | ||
} | ||
} | ||
|
||
} |
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,48 @@ | ||
/********************************************************************* | ||
* Copyright (c) 2018 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 fs from 'fs-extra'; | ||
import * as path from 'path'; | ||
|
||
/** | ||
* Generates a `cdn.json` file with the prefixes of CDN where Theia and Monaco files | ||
* should be retrieved from. | ||
* | ||
* @author David Festal | ||
*/ | ||
export class Cdn { | ||
|
||
static readonly defaultTheiaCdnPrefix = 'https://cdn.jsdelivr.net/gh/davidfestal/che-theia-cdn@latest/che-theia-editor/'; | ||
static readonly defaultMonacoCdnPrefix = 'https://cdn.jsdelivr.net/npm/'; | ||
static argBuilder = (theYargs: any) => { | ||
return theYargs.option('theia', { | ||
describe: 'Base URL of the CDN that will host Theia files', | ||
requiresArg: true, | ||
type: 'string', | ||
default: Cdn.defaultTheiaCdnPrefix, | ||
defaultDescription: Cdn.defaultTheiaCdnPrefix | ||
}).option('monaco', { | ||
describe: 'Base URL of the CDN that will host Monaco Editor files', | ||
requiresArg: true, | ||
type: 'string', | ||
default: Cdn.defaultMonacoCdnPrefix, | ||
defaultDescription: Cdn.defaultMonacoCdnPrefix | ||
}); | ||
} | ||
|
||
constructor(readonly assemblyFolder: string, readonly theiaCDN: string, readonly monacoCDN: string) { | ||
} | ||
|
||
public async create(): Promise<void> { | ||
await fs.writeFile(path.join(this.assemblyFolder, 'cdn.json'), JSON.stringify({ | ||
theia: this.theiaCDN, | ||
monaco: this.monacoCDN | ||
})); | ||
} | ||
} |
Oops, something went wrong.