Skip to content

Commit a26218d

Browse files
authored
Remove GLSP generator (#250)
fixed #247
1 parent 138e539 commit a26218d

File tree

3 files changed

+45
-126
lines changed

3 files changed

+45
-126
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ The generator allows to generate an example extension that is directly part of t
5555
| `labelprovider` | Creates a simple extension which adds a custom label (with icon) for .my files | [readme](https://github.com/eclipse-theia/generator-theia-extension/blob/master/templates/labelprovider/README.md) |
5656
| `empty` | Creates a simple, minimal extension | [readme](https://github.com/eclipse-theia/generator-theia-extension/blob/master/templates/empty/README.md) |
5757
| `backend` | Creates a backend communication extension | [readme](https://github.com/eclipse-theia/generator-theia-extension/blob/master/templates/backend/README.md) |
58-
| `diagram-editor` | Creates a diagram editor extension | [readme](https://github.com/eclipse-glsp/glsp-examples/blob/master/README.md) |
5958
| `no-extension` | Creates a Theia application without any extension | |
6059

6160

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
"author": "TypeFox",
2424
"license": "EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0",
2525
"dependencies": {
26-
"fs-extra": "^10.0.0",
27-
"request": "^2.88.2",
28-
"tar": "^6.1.1",
2926
"yeoman-generator": "^5.0.0"
3027
},
3128
"devDependencies": {

src/app/index.ts

Lines changed: 45 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ const { spawn } = require('child_process');
1818
import { execSync } from 'child_process';
1919
import path = require('path');
2020
import Base = require('yeoman-generator');
21-
const request = require('request');
22-
const tar = require('tar');
23-
const fs = require('fs-extra');
2421

25-
const glspExamplesRepositoryTag = "generator-latest";
2622
const backend = "backend";
2723
const frontend = "frontend";
2824

@@ -32,15 +28,9 @@ enum ExtensionType {
3228
LabelProvider = 'labelprovider',
3329
Empty = 'empty',
3430
Backend = 'backend',
35-
DiagramEditor = 'diagram-editor',
3631
NoExtension = 'no-extension'
3732
}
3833

39-
enum TemplateType {
40-
Java = 'java',
41-
Node = 'node',
42-
}
43-
4434
module.exports = class TheiaExtension extends Base {
4535

4636
params: {
@@ -49,7 +39,6 @@ module.exports = class TheiaExtension extends Base {
4939
license: string
5040
extensionName: string
5141
extensionType: string
52-
templateType: string
5342
unscopedExtensionName: string
5443
githubURL: string
5544
extensionPrefix: string
@@ -187,38 +176,14 @@ module.exports = class TheiaExtension extends Base {
187176
{ value: ExtensionType.LabelProvider, name: 'LabelProvider' },
188177
{ value: ExtensionType.Backend, name: 'Backend Communication' },
189178
{ value: ExtensionType.Empty, name: 'Empty' },
190-
{ value: ExtensionType.DiagramEditor, name: 'DiagramEditor' },
191179
{ value: ExtensionType.NoExtension, name: 'No Extension (just a Theia application)' }
192180
]
193181
});
194182
(this.options as any).extensionType = answer.type;
195-
196-
if (answer.type === ExtensionType.DiagramEditor) {
197-
const answer = await this.prompt({
198-
type: 'list',
199-
name: 'backend',
200-
message: 'Which GLSP backend do you want to use, i.e. in which language do you prefer to develop your GLSP server?',
201-
choices: [
202-
{ value: TemplateType.Java, name: 'Java (requires maven!)' },
203-
{ value: TemplateType.Node, name: 'Node (TypeScript)' },
204-
]
205-
});
206-
let template = answer.backend;
207-
208-
(this.options as any).templateType = template;
209-
210-
if(template === TemplateType.Java) {
211-
this.log('\x1b[32m%s\x1b[0m', 'The template will use an EMF source model on the server and generate a Theia extension ✓')
212-
}
213-
if(template === TemplateType.Node) {
214-
this.log('\x1b[32m%s\x1b[0m', 'The template will use a JSON based source model, node as a server and generate a Theia extension ✓')
215-
}
216-
}
217183
}
218184

219185
let extensionName = (this.options as any).extensionName;
220-
// extensionName is not used within the DiagramEditor
221-
if (!extensionName && this.options.extensionType !== ExtensionType.DiagramEditor && this.options.extensionType !== ExtensionType.NoExtension) {
186+
if (!extensionName && this.options.extensionType !== ExtensionType.NoExtension) {
222187
const answer = await this.prompt({
223188
type: 'input',
224189
name: 'name',
@@ -243,7 +208,6 @@ module.exports = class TheiaExtension extends Base {
243208
extensionPrefix = extensionPath.split('-').map(name => this._capitalize(name)).join('');
244209
}
245210
const extensionType = options.extensionType;
246-
const templateType = options.templateType;
247211
const githubURL = options.githubURL;
248212
this.log(extensionPrefix);
249213
this.params = {
@@ -253,7 +217,6 @@ module.exports = class TheiaExtension extends Base {
253217
extensionPath,
254218
extensionPrefix,
255219
extensionType,
256-
templateType,
257220
githubURL,
258221
theiaVersion: options["theia-version"],
259222
lernaVersion: options["lerna-version"],
@@ -269,7 +232,7 @@ module.exports = class TheiaExtension extends Base {
269232
this.params.containsTests = true;
270233
}
271234
options.params = this.params
272-
if (!options.standalone && this.params.extensionType !== ExtensionType.DiagramEditor) {
235+
if (!options.standalone) {
273236
if (options.browser) {
274237
this.composeWith(require.resolve('../browser'), this.options);
275238
}
@@ -284,50 +247,48 @@ module.exports = class TheiaExtension extends Base {
284247
}
285248

286249
async writing() {
287-
if (this.params.extensionType !== ExtensionType.DiagramEditor) {
288-
if (!this.options.standalone) {
289-
/** common templates */
290-
this.fs.copyTpl(
291-
this.templatePath('root-package.json'),
292-
this.destinationPath('package.json'),
293-
{ params: this.params }
294-
);
295-
this.fs.copyTpl(
296-
this.templatePath('lerna.json'),
297-
this.destinationPath('lerna.json'),
298-
{ params: this.params }
299-
);
300-
this.fs.copyTpl(
301-
this.templatePath('gitignore'),
302-
this.destinationPath('.gitignore'),
303-
{ params: this.params }
304-
);
305-
this.fs.copyTpl(
306-
this.templatePath('README.md'),
307-
this.destinationPath('README.md'),
308-
{ params: this.params }
309-
);
310-
if (this.params.vscode) {
311-
this.fs.copyTpl(
312-
this.templatePath('launch.json'),
313-
this.destinationPath('.vscode/launch.json'),
314-
{ params: this.params }
315-
);
316-
}
317-
}
318-
if(this.params.extensionType !== ExtensionType.NoExtension){
319-
this.fs.copyTpl(
320-
this.templatePath('extension-package.json'),
321-
this.extensionPath('package.json'),
322-
{ params: this.params }
323-
);
250+
if (!this.options.standalone) {
251+
/** common templates */
252+
this.fs.copyTpl(
253+
this.templatePath('root-package.json'),
254+
this.destinationPath('package.json'),
255+
{ params: this.params }
256+
);
257+
this.fs.copyTpl(
258+
this.templatePath('lerna.json'),
259+
this.destinationPath('lerna.json'),
260+
{ params: this.params }
261+
);
262+
this.fs.copyTpl(
263+
this.templatePath('gitignore'),
264+
this.destinationPath('.gitignore'),
265+
{ params: this.params }
266+
);
267+
this.fs.copyTpl(
268+
this.templatePath('README.md'),
269+
this.destinationPath('README.md'),
270+
{ params: this.params }
271+
);
272+
if (this.params.vscode) {
324273
this.fs.copyTpl(
325-
this.templatePath('tsconfig.json'),
326-
this.extensionPath('tsconfig.json'),
274+
this.templatePath('launch.json'),
275+
this.destinationPath('.vscode/launch.json'),
327276
{ params: this.params }
328277
);
329278
}
330279
}
280+
if(this.params.extensionType !== ExtensionType.NoExtension){
281+
this.fs.copyTpl(
282+
this.templatePath('extension-package.json'),
283+
this.extensionPath('package.json'),
284+
{ params: this.params }
285+
);
286+
this.fs.copyTpl(
287+
this.templatePath('tsconfig.json'),
288+
this.extensionPath('tsconfig.json'),
289+
{ params: this.params }
290+
);
291+
}
331292

332293
/** hello-world */
333294
if (this.params.extensionType === ExtensionType.HelloWorld) {
@@ -468,29 +429,6 @@ module.exports = class TheiaExtension extends Base {
468429
{ params: this.params }
469430
);
470431
}
471-
472-
/** DiagramEditor */
473-
if (this.params.extensionType === ExtensionType.DiagramEditor) {
474-
const baseDir = `./glsp-examples-${glspExamplesRepositoryTag}`;
475-
let templatePath = '';
476-
if(this.params.templateType == TemplateType.Java) {
477-
templatePath = '/project-templates/java-emf-theia';
478-
} else if (this.params.templateType == TemplateType.Node) {
479-
templatePath = '/project-templates/node-json-theia';
480-
} else {
481-
return;
482-
}
483-
484-
return new Promise<void>((resolve) => {
485-
request.get(`https://github.com/eclipse-glsp/glsp-examples/archive/refs/tags/${glspExamplesRepositoryTag}.tar.gz`).pipe(tar.x().on('close',() => {
486-
fs.copy(baseDir+'/README.md', './README.md');
487-
fs.copy(baseDir+templatePath, './').then(() => {
488-
fs.rm(baseDir, { recursive: true });
489-
resolve();
490-
});
491-
}));
492-
});
493-
}
494432
}
495433

496434
protected extensionPath(...paths: string[]) {
@@ -522,25 +460,11 @@ module.exports = class TheiaExtension extends Base {
522460
console.log(`yarn process exited with code ${code}`);
523461
});
524462

525-
if (this.params.extensionType == ExtensionType.DiagramEditor) {
526-
command.on('close', (code:number) => {
527-
if (code === 0 ) {
528-
this.log(
529-
'\x1b[32m%s\x1b[0m',
530-
'\nThe DiagramEditor Example has been generated and all dependencies installed\n\nCheck the Readme to get started.'
531-
);
532-
} else {
533-
this.log('\x1b[31m%s\x1b[0m','Command "yarn" failed. Please see above for the reported error message.');
534-
process.exit(code);
535-
}
536-
});
537-
} else {
538-
command.on('close', function(code: number){
539-
if (code !== 0 ) {
540-
process.exit(code);
541-
}
542-
})
543-
}
463+
command.on('close', function(code: number){
464+
if (code !== 0 ) {
465+
process.exit(code);
466+
}
467+
});
544468

545469
return command;
546470
}
@@ -568,5 +492,4 @@ module.exports = class TheiaExtension extends Base {
568492
}
569493
}
570494

571-
module.exports.ExtensionType = ExtensionType;
572-
495+
module.exports.ExtensionType = ExtensionType;

0 commit comments

Comments
 (0)