Skip to content

Commit

Permalink
Allow to generate no extension (#230)
Browse files Browse the repository at this point in the history
fixed #229

Signed-off-by: Jonas Helming <[email protected]>
  • Loading branch information
JonasHelming authored Oct 16, 2024
1 parent cc7fe4d commit 584887f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 22 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<br />
<img src='https://raw.githubusercontent.com/theia-ide/generator-theia-extension/master/logo/theia.svg?sanitize=true' alt='theia logo' width='125'>

<h2>ECLIPSE THEIA - EXTENSION GENERATOR</h2>
<h2>ECLIPSE THEIA - GENERATOR</h2>



Expand All @@ -11,8 +11,12 @@

<br />

A [yeoman](https://yeoman.io/) generator that scaffolds a project structure for developing [Eclipse Theia](https://github.com/eclipse-theia/theia) extensions.
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.

Please also see:

- [Build your own IDE/Tool based on Eclipse Theia](https://theia-ide.org/docs/composing_applications/)
- [Authoring Theia Extensions](https://theia-ide.org/docs/authoring_extensions/)

<br />

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

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

```
mkdir my-extension && cd my-extension
mkdir my-theia-app && cd my-theia-app
yo theia-extension
```

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

## Extension Options

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.

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



Expand Down
30 changes: 17 additions & 13 deletions src/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ enum ExtensionType {
TreeEditor = 'tree-editor',
Empty = 'empty',
Backend = 'backend',
DiagramEditor = 'diagram-editor'
DiagramEditor = 'diagram-editor',
NoExtension = 'no-extension'
}

enum TemplateType {
Expand Down Expand Up @@ -176,7 +177,8 @@ module.exports = class TheiaExtension extends Base {
{ value: ExtensionType.TreeEditor, name: 'TreeEditor' },
{ value: ExtensionType.Backend, name: 'Backend Communication' },
{ value: ExtensionType.Empty, name: 'Empty' },
{ value: ExtensionType.DiagramEditor, name: 'DiagramEditor' }
{ value: ExtensionType.DiagramEditor, name: 'DiagramEditor' },
{ value: ExtensionType.NoExtension, name: 'No Extension (just a Theia application)' }
]
});
(this.options as any).extensionType = answer.type;
Expand Down Expand Up @@ -206,7 +208,7 @@ module.exports = class TheiaExtension extends Base {

let extensionName = (this.options as any).extensionName;
// extensionName is not used within the DiagramEditor
if (!extensionName && this.options.extensionType !== ExtensionType.DiagramEditor) {
if (!extensionName && this.options.extensionType !== ExtensionType.DiagramEditor && this.options.extensionType !== ExtensionType.NoExtension) {
const answer = await this.prompt({
type: 'input',
name: 'name',
Expand Down Expand Up @@ -306,16 +308,18 @@ module.exports = class TheiaExtension extends Base {
);
}
}
this.fs.copyTpl(
this.templatePath('extension-package.json'),
this.extensionPath('package.json'),
{ params: this.params }
);
this.fs.copyTpl(
this.templatePath('tsconfig.json'),
this.extensionPath('tsconfig.json'),
{ params: this.params }
);
if(this.params.extensionType !== ExtensionType.NoExtension){
this.fs.copyTpl(
this.templatePath('extension-package.json'),
this.extensionPath('package.json'),
{ params: this.params }
);
this.fs.copyTpl(
this.templatePath('tsconfig.json'),
this.extensionPath('tsconfig.json'),
{ params: this.params }
);
}
}

/** hello-world */
Expand Down
4 changes: 2 additions & 2 deletions templates/app-browser-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"@theia/preferences": "<%= params.theiaVersion %>",
"@theia/process": "<%= params.theiaVersion %>",
"@theia/terminal": "<%= params.theiaVersion %>",
"@theia/workspace": "<%= params.theiaVersion %>",
"<%= params.extensionName %>": "<%= params.version %>"
"@theia/workspace": "<%= params.theiaVersion %>"<% if (params.extensionName) { %>,
"<%= params.extensionName %>": "<%= params.version %>"<% } %>
},
"devDependencies": {
"@theia/cli": "<%= params.theiaVersion %>"<% if (params.browserDevDependencies) { %><%- params.browserDevDependencies %><% } %>
Expand Down
4 changes: 2 additions & 2 deletions templates/app-electron-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"@theia/preferences": "<%= params.theiaVersion %>",
"@theia/process": "<%= params.theiaVersion %>",
"@theia/terminal": "<%= params.theiaVersion %>",
"@theia/workspace": "<%= params.theiaVersion %>",
"<%= params.extensionName %>": "<%= params.version %>"
"@theia/workspace": "<%= params.theiaVersion %>"<% if (params.extensionName) { %>,
"<%= params.extensionName %>": "<%= params.version %>"<% } %>
},
"devDependencies": {
"@theia/cli": "<%= params.theiaVersion %>",
Expand Down
2 changes: 1 addition & 1 deletion templates/root-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"lerna": "<%= params.lernaVersion %>"
},
"workspaces": [
"<%= params.extensionPath %>"<% if (params.browser) { %>, "browser-app"<% } %><% if (params.electron) { %>, "electron-app"<% } %>
<% if (params.extensionName) { %>"<%= params.extensionPath %>"<% } %><% if (params.browser) { %><% if (params.extensionName) { %>,<% } %> "browser-app"<% } %><% if (params.electron) { %><% if (params.extensionName||params.browser) { %>,<% } %> "electron-app"<% } %>
]
}

0 comments on commit 584887f

Please sign in to comment.