Skip to content

Commit 584887f

Browse files
authored
Allow to generate no extension (#230)
fixed #229 Signed-off-by: Jonas Helming <[email protected]>
1 parent cc7fe4d commit 584887f

File tree

5 files changed

+32
-22
lines changed

5 files changed

+32
-22
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<br />
33
<img src='https://raw.githubusercontent.com/theia-ide/generator-theia-extension/master/logo/theia.svg?sanitize=true' alt='theia logo' width='125'>
44

5-
<h2>ECLIPSE THEIA - EXTENSION GENERATOR</h2>
5+
<h2>ECLIPSE THEIA - GENERATOR</h2>
66

77

88

@@ -11,8 +11,12 @@
1111

1212
<br />
1313

14-
A [yeoman](https://yeoman.io/) generator that scaffolds a project structure for developing [Eclipse Theia](https://github.com/eclipse-theia/theia) extensions.
14+
A [yeoman](https://yeoman.io/) generator that scaffolds a project structure for developing custom [Eclipse Theia](https://github.com/eclipse-theia/theia) applications and extensions.
1515

16+
Please also see:
17+
18+
- [Build your own IDE/Tool based on Eclipse Theia](https://theia-ide.org/docs/composing_applications/)
19+
- [Authoring Theia Extensions](https://theia-ide.org/docs/authoring_extensions/)
1620

1721
<br />
1822

@@ -27,10 +31,10 @@ To use it, install `yo` (version 4.x.x) and the `generator` (see next below).
2731
npm install -g yo generator-theia-extension
2832
```
2933

30-
To create a sample project with a Theia extension including a browser and electron app, run:
34+
To create a sample Theia project (optionally with custom Theia extensions) including a browser and electron app, run:
3135

3236
```
33-
mkdir my-extension && cd my-extension
37+
mkdir my-theia-app && cd my-theia-app
3438
yo theia-extension
3539
```
3640

@@ -42,6 +46,7 @@ yo theia-extension --help
4246

4347
## Extension Options
4448

49+
The generator allows to generate an example extension that is directly part of the generated Theia application. Alternativly, you can select 'no-extension' to just generate a Theia application without a custom extension.
4550

4651
| Template Option | Description | Documentation |
4752
|:---|:---|:---|
@@ -52,6 +57,7 @@ yo theia-extension --help
5257
| `empty` | Creates a simple, minimal extension | [readme](https://github.com/eclipse-theia/generator-theia-extension/blob/master/templates/empty/README.md) |
5358
| `backend` | Creates a backend communication extension | [readme](https://github.com/eclipse-theia/generator-theia-extension/blob/master/templates/backend/README.md) |
5459
| `diagram-editor` | Creates a diagram editor extension | [readme](https://github.com/eclipse-glsp/glsp-examples/blob/master/README.md) |
60+
| `no-extension` | Creates a Theia application without any extension | |
5561

5662

5763

src/app/index.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ enum ExtensionType {
3232
TreeEditor = 'tree-editor',
3333
Empty = 'empty',
3434
Backend = 'backend',
35-
DiagramEditor = 'diagram-editor'
35+
DiagramEditor = 'diagram-editor',
36+
NoExtension = 'no-extension'
3637
}
3738

3839
enum TemplateType {
@@ -176,7 +177,8 @@ module.exports = class TheiaExtension extends Base {
176177
{ value: ExtensionType.TreeEditor, name: 'TreeEditor' },
177178
{ value: ExtensionType.Backend, name: 'Backend Communication' },
178179
{ value: ExtensionType.Empty, name: 'Empty' },
179-
{ value: ExtensionType.DiagramEditor, name: 'DiagramEditor' }
180+
{ value: ExtensionType.DiagramEditor, name: 'DiagramEditor' },
181+
{ value: ExtensionType.NoExtension, name: 'No Extension (just a Theia application)' }
180182
]
181183
});
182184
(this.options as any).extensionType = answer.type;
@@ -206,7 +208,7 @@ module.exports = class TheiaExtension extends Base {
206208

207209
let extensionName = (this.options as any).extensionName;
208210
// extensionName is not used within the DiagramEditor
209-
if (!extensionName && this.options.extensionType !== ExtensionType.DiagramEditor) {
211+
if (!extensionName && this.options.extensionType !== ExtensionType.DiagramEditor && this.options.extensionType !== ExtensionType.NoExtension) {
210212
const answer = await this.prompt({
211213
type: 'input',
212214
name: 'name',
@@ -306,16 +308,18 @@ module.exports = class TheiaExtension extends Base {
306308
);
307309
}
308310
}
309-
this.fs.copyTpl(
310-
this.templatePath('extension-package.json'),
311-
this.extensionPath('package.json'),
312-
{ params: this.params }
313-
);
314-
this.fs.copyTpl(
315-
this.templatePath('tsconfig.json'),
316-
this.extensionPath('tsconfig.json'),
317-
{ params: this.params }
318-
);
311+
if(this.params.extensionType !== ExtensionType.NoExtension){
312+
this.fs.copyTpl(
313+
this.templatePath('extension-package.json'),
314+
this.extensionPath('package.json'),
315+
{ params: this.params }
316+
);
317+
this.fs.copyTpl(
318+
this.templatePath('tsconfig.json'),
319+
this.extensionPath('tsconfig.json'),
320+
{ params: this.params }
321+
);
322+
}
319323
}
320324

321325
/** hello-world */

templates/app-browser-package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"@theia/preferences": "<%= params.theiaVersion %>",
1414
"@theia/process": "<%= params.theiaVersion %>",
1515
"@theia/terminal": "<%= params.theiaVersion %>",
16-
"@theia/workspace": "<%= params.theiaVersion %>",
17-
"<%= params.extensionName %>": "<%= params.version %>"
16+
"@theia/workspace": "<%= params.theiaVersion %>"<% if (params.extensionName) { %>,
17+
"<%= params.extensionName %>": "<%= params.version %>"<% } %>
1818
},
1919
"devDependencies": {
2020
"@theia/cli": "<%= params.theiaVersion %>"<% if (params.browserDevDependencies) { %><%- params.browserDevDependencies %><% } %>

templates/app-electron-package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"@theia/preferences": "<%= params.theiaVersion %>",
1616
"@theia/process": "<%= params.theiaVersion %>",
1717
"@theia/terminal": "<%= params.theiaVersion %>",
18-
"@theia/workspace": "<%= params.theiaVersion %>",
19-
"<%= params.extensionName %>": "<%= params.version %>"
18+
"@theia/workspace": "<%= params.theiaVersion %>"<% if (params.extensionName) { %>,
19+
"<%= params.extensionName %>": "<%= params.version %>"<% } %>
2020
},
2121
"devDependencies": {
2222
"@theia/cli": "<%= params.theiaVersion %>",

templates/root-package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
"lerna": "<%= params.lernaVersion %>"
1919
},
2020
"workspaces": [
21-
"<%= params.extensionPath %>"<% if (params.browser) { %>, "browser-app"<% } %><% if (params.electron) { %>, "electron-app"<% } %>
21+
<% if (params.extensionName) { %>"<%= params.extensionPath %>"<% } %><% if (params.browser) { %><% if (params.extensionName) { %>,<% } %> "browser-app"<% } %><% if (params.electron) { %><% if (params.extensionName||params.browser) { %>,<% } %> "electron-app"<% } %>
2222
]
2323
}

0 commit comments

Comments
 (0)