diff --git a/theia-extensions/theia-cf-manifest-yaml/cf-manifest-yaml/src/browser/cf-manifest-yaml-contribution.ts b/theia-extensions/theia-cf-manifest-yaml/cf-manifest-yaml/src/browser/cf-manifest-yaml-contribution.ts new file mode 100644 index 000000000..5f1e97bbf --- /dev/null +++ b/theia-extensions/theia-cf-manifest-yaml/cf-manifest-yaml/src/browser/cf-manifest-yaml-contribution.ts @@ -0,0 +1,33 @@ +import { injectable, inject } from "inversify"; +import { CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry, MessageService } from "@theia/core/lib/common"; +import { CommonMenus } from "@theia/core/lib/browser"; + +export const CfManifestYamlCommand = { + id: 'CfManifestYaml.command', + label: "Shows a message" +}; + +@injectable() +export class CfManifestYamlCommandContribution implements CommandContribution { + + constructor( + @inject(MessageService) private readonly messageService: MessageService, + ) { } + + registerCommands(registry: CommandRegistry): void { + registry.registerCommand(CfManifestYamlCommand, { + execute: () => this.messageService.info('Hello World!') + }); + } +} + +@injectable() +export class CfManifestYamlMenuContribution implements MenuContribution { + + registerMenus(menus: MenuModelRegistry): void { + menus.registerMenuAction(CommonMenus.EDIT_FIND, { + commandId: CfManifestYamlCommand.id, + label: 'Say Hello' + }); + } +} \ No newline at end of file diff --git a/theia-extensions/theia-cf-manifest-yaml/properties.json b/theia-extensions/theia-cf-manifest-yaml/properties.json new file mode 100644 index 000000000..8b84198ce --- /dev/null +++ b/theia-extensions/theia-cf-manifest-yaml/properties.json @@ -0,0 +1,3 @@ +{ + "jarUrl": "https://s3-us-west-1.amazonaws.com/s3-test.spring.io/sts4/fatjars/snapshots/manifest-yaml-language-server-0.1.5-201803080105.jar" +} diff --git a/theia-extensions/theia-cf-manifest-yaml/script.js b/theia-extensions/theia-cf-manifest-yaml/script.js new file mode 100644 index 000000000..d7b1bd357 --- /dev/null +++ b/theia-extensions/theia-cf-manifest-yaml/script.js @@ -0,0 +1,34 @@ +const fs = require('fs'); +const path = require('path'); +const download = require('download'); +const PROPERTIES = require('./properties.json'); + +let fileExists = function(path) { + return new Promise((resolve, reject) => { + fs.access(path, fs.R_OK, error => { + resolve(!error || error.code !== 'ENOENT'); + }) + }); +}; + +const serverDownloadUrl = PROPERTIES.jarUrl; + +const serverHome = path.join(__dirname, 'server'); + +const localFileName = path.join(serverHome, 'cf-manifest-language-server.jar'); + +fileExists(localFileName).then(exists => { + if (!exists) { + console.log(`Downloading ${serverDownloadUrl} to ${localFileName}`); + fileExists(serverHome) + .then(doesExist => { if (!doesExist) fs.mkdir(serverHome) }) + .then(() => download(serverDownloadUrl)) + .then(data => fs.writeFileSync(localFileName, data)) + .then(() => fileExists(localFileName)) + .then(doesExist => { if (!doesExist) throw Error(`Failed to install the ${this.getServerName()} language server`) }) + .then(() => console.log(`Successfully downloaded ${serverDownloadUrl}`)); + } +}); + + + diff --git a/theia-extensions/theia-cf-manifest-yaml/src/browser/cf-manifest-yaml-contribution.ts b/theia-extensions/theia-cf-manifest-yaml/src/browser/cf-manifest-yaml-contribution.ts new file mode 100644 index 000000000..5943d5ea1 --- /dev/null +++ b/theia-extensions/theia-cf-manifest-yaml/src/browser/cf-manifest-yaml-contribution.ts @@ -0,0 +1,33 @@ +import { injectable, inject } from "inversify"; +import { CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry, MessageService } from "@theia/core/lib/common"; +import { CommonMenus } from "@theia/core/lib/browser"; + +export const HelloWorldCommand = { + id: 'HelloWorld.command', + label: "Shows a message" +}; + +@injectable() +export class HelloWorldCommandContribution implements CommandContribution { + + constructor( + @inject(MessageService) private readonly messageService: MessageService, + ) { } + + registerCommands(registry: CommandRegistry): void { + registry.registerCommand(HelloWorldCommand, { + execute: () => this.messageService.info('Hello World!') + }); + } +} + +@injectable() +export class HelloWorldMenuContribution implements MenuContribution { + + registerMenus(menus: MenuModelRegistry): void { + menus.registerMenuAction(CommonMenus.EDIT_FIND, { + commandId: HelloWorldCommand.id, + label: 'Say Hello' + }); + } +} \ No newline at end of file diff --git a/theia-extensions/theia-cf-manifest-yaml/src/browser/cf-manifest-yaml-frontend-module.ts b/theia-extensions/theia-cf-manifest-yaml/src/browser/cf-manifest-yaml-frontend-module.ts new file mode 100644 index 000000000..2b38dde6e --- /dev/null +++ b/theia-extensions/theia-cf-manifest-yaml/src/browser/cf-manifest-yaml-frontend-module.ts @@ -0,0 +1,19 @@ +/** + * Generated using theia-extension-generator + */ + +import { HelloWorldCommandContribution, HelloWorldMenuContribution } from './hello-world-contribution'; +import { + CommandContribution, + MenuContribution +} from "@theia/core/lib/common"; + +import { ContainerModule } from "inversify"; + +export default new ContainerModule(bind => { + // add your contribution bindings here + + bind(CommandContribution).to(HelloWorldCommandContribution); + bind(MenuContribution).to(HelloWorldMenuContribution); + +}); \ No newline at end of file diff --git a/theia-extensions/theia-cf-manifest-yaml/tsconfig.json b/theia-extensions/theia-cf-manifest-yaml/tsconfig.json new file mode 100644 index 000000000..49638176a --- /dev/null +++ b/theia-extensions/theia-cf-manifest-yaml/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../configs/base.tsconfig", + "compilerOptions": { + "rootDir": "src", + "outDir": "lib" + }, + "include": [ + "src" + ] +} \ No newline at end of file