Skip to content

Commit

Permalink
initial commit; generated Hello world extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonah Iden committed Aug 24, 2022
0 parents commit e02ee7c
Show file tree
Hide file tree
Showing 12 changed files with 356 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
.browser_modules
lib
*.log
*-app/*
!*-app/package.json
60 changes: 60 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Start Browser Backend",
"program": "${workspaceRoot}/browser-app/src-gen/backend/main.js",
"args": [
"--loglevel=debug",
"--port=3000",
"--no-cluster"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js",
"${workspaceRoot}/*/lib/**/*.js",
"${workspaceRoot}/browser-app/src-gen/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Start Electron Backend",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"program": "${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"protocol": "inspector",
"args": [
"--loglevel=debug",
"--hostname=localhost",
"--no-cluster"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"${workspaceRoot}/electron-app/src-gen/backend/main.js",
"${workspaceRoot}/*/lib/**/*.js",
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
}
]
}
89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# typefox-test
The example of how to build the Theia-based applications with the typefox-test.

## Getting started

Install [nvm](https://github.com/creationix/nvm#install-script).

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash

Install npm and node.

nvm install 10
nvm use 10

Install yarn.

npm install -g yarn

## Running the browser example

yarn start:browser

*or:*

yarn rebuild:browser
cd browser-app
yarn start

*or:* launch `Start Browser Backend` configuration from VS code.

Open http://localhost:3000 in the browser.

## Running the Electron example

yarn start:electron

*or:*

yarn rebuild:electron
cd electron-app
yarn start

*or:* launch `Start Electron Backend` configuration from VS code.


## Developing with the browser example

Start watching all packages, including `browser-app`, of your application with

yarn watch

*or* watch only specific packages with

cd typefox-test
yarn watch

and the browser example.

cd browser-app
yarn watch

Run the example as [described above](#Running-the-browser-example)
## Developing with the Electron example

Start watching all packages, including `electron-app`, of your application with

yarn watch

*or* watch only specific packages with

cd typefox-test
yarn watch

and the Electron example.

cd electron-app
yarn watch

Run the example as [described above](#Running-the-Electron-example)

## Publishing typefox-test

Create a npm user and login to the npm registry, [more on npm publishing](https://docs.npmjs.com/getting-started/publishing-npm-packages).

npm login

Publish packages with lerna to update versions properly across local packages, [more on publishing with lerna](https://github.com/lerna/lerna#publish).

npx lerna publish
30 changes: 30 additions & 0 deletions browser-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"private": true,
"name": "browser-app",
"version": "0.0.0",
"dependencies": {
"@theia/core": "latest",
"@theia/editor": "latest",
"@theia/filesystem": "latest",
"@theia/markers": "latest",
"@theia/messages": "latest",
"@theia/monaco": "latest",
"@theia/navigator": "latest",
"@theia/preferences": "latest",
"@theia/process": "latest",
"@theia/terminal": "latest",
"@theia/workspace": "latest",
"typefox-test": "0.0.0"
},
"devDependencies": {
"@theia/cli": "latest"
},
"scripts": {
"prepare": "theia build --mode development",
"start": "theia start",
"watch": "theia build --watch --mode development"
},
"theia": {
"target": "browser"
}
}
32 changes: 32 additions & 0 deletions electron-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"private": true,
"name": "electron-app",
"version": "0.0.0",
"dependencies": {
"@theia/core": "latest",
"@theia/editor": "latest",
"@theia/electron": "latest",
"@theia/filesystem": "latest",
"@theia/markers": "latest",
"@theia/messages": "latest",
"@theia/monaco": "latest",
"@theia/navigator": "latest",
"@theia/preferences": "latest",
"@theia/process": "latest",
"@theia/terminal": "latest",
"@theia/workspace": "latest",
"typefox-test": "0.0.0"
},
"devDependencies": {
"@theia/cli": "latest",
"electron": "^15.3.5"
},
"scripts": {
"prepare": "theia build --mode development",
"start": "theia start",
"watch": "theia build --watch --mode development"
},
"theia": {
"target": "electron"
}
}
11 changes: 11 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"lerna": "2.4.0",
"version": "0.0.0",
"useWorkspaces": true,
"npmClient": "yarn",
"command": {
"run": {
"stream": true
}
}
}
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"private": true,
"scripts": {
"prepare": "lerna run prepare",
"rebuild:browser": "theia rebuild:browser",
"rebuild:electron": "theia rebuild:electron",
"start:browser": "yarn rebuild:browser && yarn --cwd browser-app start",
"start:electron": "yarn rebuild:electron && yarn --cwd electron-app start",
"watch": "lerna run --parallel watch"
},
"devDependencies": {
"lerna": "2.4.0"
},
"workspaces": [
"typefox-test", "browser-app", "electron-app"
]
}
7 changes: 7 additions & 0 deletions typefox-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Hello World Example

The example extension demonstrates how to register a command in Theia saying "Hello world" using the message service.

## How to use the Hello World example

In the running application, trigger the command "Say hello" via the command palette (F1 => "Say Hello"). A message dialog will pop up saying "Hello World".
29 changes: 29 additions & 0 deletions typefox-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "typefox-test",
"keywords": [
"theia-extension"
],
"version": "0.0.0",
"files": [
"lib",
"src"
],
"dependencies": {
"@theia/core": "latest"
},
"devDependencies": {
"rimraf": "latest",
"typescript": "latest"
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib",
"build": "tsc",
"watch": "tsc -w"
},
"theiaExtensions": [
{
"frontend": "lib/browser/typefox-test-frontend-module"
}
]
}
33 changes: 33 additions & 0 deletions typefox-test/src/browser/typefox-test-contribution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { injectable, inject } from '@theia/core/shared/inversify';
import { Command, CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry, MessageService } from '@theia/core/lib/common';
import { CommonMenus } from '@theia/core/lib/browser';

export const TypefoxTestCommand: Command = {
id: 'TypefoxTest.command',
label: 'Say Hello'
};

@injectable()
export class TypefoxTestCommandContribution implements CommandContribution {

constructor(
@inject(MessageService) private readonly messageService: MessageService,
) { }

registerCommands(registry: CommandRegistry): void {
registry.registerCommand(TypefoxTestCommand, {
execute: () => this.messageService.info('Hello World!')
});
}
}

@injectable()
export class TypefoxTestMenuContribution implements MenuContribution {

registerMenus(menus: MenuModelRegistry): void {
menus.registerMenuAction(CommonMenus.EDIT_FIND, {
commandId: TypefoxTestCommand.id,
label: TypefoxTestCommand.label
});
}
}
12 changes: 12 additions & 0 deletions typefox-test/src/browser/typefox-test-frontend-module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Generated using theia-extension-generator
*/
import { TypefoxTestCommandContribution, TypefoxTestMenuContribution } from './typefox-test-contribution';
import { CommandContribution, MenuContribution } from '@theia/core/lib/common';
import { ContainerModule } from '@theia/core/shared/inversify';

export default new ContainerModule(bind => {
// add your contribution bindings here
bind(CommandContribution).to(TypefoxTestCommandContribution);
bind(MenuContribution).to(TypefoxTestMenuContribution);
});
30 changes: 30 additions & 0 deletions typefox-test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"compilerOptions": {
"skipLibCheck": true,
"declaration": true,
"declarationMap": true,
"noImplicitAny": true,
"noEmitOnError": false,
"noImplicitThis": true,
"noUnusedLocals": true,
"strictNullChecks": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"downlevelIteration": true,
"resolveJsonModule": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "ES2017",
"jsx": "react",
"lib": [
"ES2017",
"dom"
],
"sourceMap": true,
"rootDir": "src",
"outDir": "lib"
},
"include": [
"src"
]
}

0 comments on commit e02ee7c

Please sign in to comment.