diff --git a/assembly/assembly-wsagent-war/pom.xml b/assembly/assembly-wsagent-war/pom.xml index 66ffaa72c0..b2bf97b031 100644 --- a/assembly/assembly-wsagent-war/pom.xml +++ b/assembly/assembly-wsagent-war/pom.xml @@ -228,6 +228,14 @@ org.eclipse.che.plugin che-plugin-zend-debugger-server + + org.eclipse.che.plugin + che-plugin-web-ext-server + + + org.eclipse.che.plugin + che-plugin-web-ext-shared + org.everrest everrest-core diff --git a/ide/che-core-ide-templates/src/main/resources/samples.json b/ide/che-core-ide-templates/src/main/resources/samples.json index 5a43d7e0cb..d6dca37870 100644 --- a/ide/che-core-ide-templates/src/main/resources/samples.json +++ b/ide/che-core-ide-templates/src/main/resources/samples.json @@ -1421,5 +1421,37 @@ "tags": [ "Platformio" ] + }, + { + "name": "typescript-greeter", + "displayName": "typescript-greeter", + "path": "/mbed-blink", + "description": "TypeScript greeter sample", + "projectType": "typescript", + "mixins": [], + "attributes": { + "language": [ + "typescript" + ] + }, + "modules": [], + "problems": [], + "source": { + "type": "git", + "location": "https://github.com/Microsoft/TypeScriptSamples.git", + "parameters": { + "keepDir":"greeter", + "keepVcs": "false", + "convertToTopLevelProject": "true" + } + }, + "commands": [ + + ], + "links": [], + "category": "Samples", + "tags": [ + "TypeScript","ts" + ] } ] diff --git a/plugins/plugin-web/che-plugin-web-ext-server/pom.xml b/plugins/plugin-web/che-plugin-web-ext-server/pom.xml new file mode 100644 index 0000000000..a519866b61 --- /dev/null +++ b/plugins/plugin-web/che-plugin-web-ext-server/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + che-plugin-web-parent + org.eclipse.che.plugin + 5.0.0-M8-SNAPSHOT + + che-plugin-web-ext-server + + + com.google.inject + guice + + + com.google.inject.extensions + guice-multibindings + + + io.typefox.lsapi + io.typefox.lsapi.services + + + javax.inject + javax.inject + + + org.eclipse.che.core + che-core-api-languageserver + + + org.eclipse.che.core + che-core-api-languageserver-shared + + + org.eclipse.che.core + che-core-api-project + + + org.eclipse.che.core + che-core-commons-inject + + + org.eclipse.che.plugin + che-plugin-web-ext-shared + + + org.testng + testng + test + + + diff --git a/plugins/plugin-web/che-plugin-web-ext-server/src/main/java/org/eclipse/che/plugin/web/inject/WebModule.java b/plugins/plugin-web/che-plugin-web-ext-server/src/main/java/org/eclipse/che/plugin/web/inject/WebModule.java new file mode 100644 index 0000000000..f8333908e6 --- /dev/null +++ b/plugins/plugin-web/che-plugin-web-ext-server/src/main/java/org/eclipse/che/plugin/web/inject/WebModule.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.web.inject; + +import com.google.inject.AbstractModule; +import com.google.inject.multibindings.Multibinder; + +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; +import org.eclipse.che.api.project.server.type.ProjectTypeDef; +import org.eclipse.che.inject.DynaModule; +import org.eclipse.che.plugin.web.typescript.TSLSLauncher; +import org.eclipse.che.plugin.web.typescript.TypeScriptProjectType; + +/** + * The module that contains configuration of the server side part of the Web plugin + */ +@DynaModule +public class WebModule extends AbstractModule { + + @Override + protected void configure() { + Multibinder projectTypeMultibinder = Multibinder.newSetBinder(binder(), ProjectTypeDef.class); + projectTypeMultibinder.addBinding().to(TypeScriptProjectType.class); + + Multibinder.newSetBinder(binder(), LanguageServerLauncher.class).addBinding().to(TSLSLauncher.class); + } +} diff --git a/plugins/plugin-web/che-plugin-web-ext-server/src/main/java/org/eclipse/che/plugin/web/typescript/TSLSLauncher.java b/plugins/plugin-web/che-plugin-web-ext-server/src/main/java/org/eclipse/che/plugin/web/typescript/TSLSLauncher.java new file mode 100644 index 0000000000..0ec052f625 --- /dev/null +++ b/plugins/plugin-web/che-plugin-web-ext-server/src/main/java/org/eclipse/che/plugin/web/typescript/TSLSLauncher.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.web.typescript; + +import io.typefox.lsapi.services.LanguageServer; +import io.typefox.lsapi.services.json.JsonBasedLanguageServer; + +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncherTemplate; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.model.impl.LanguageDescriptionImpl; +import org.eclipse.che.plugin.web.shared.Constants; + +import javax.inject.Singleton; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static java.util.Arrays.asList; + +/** + * Launcher for TypeScript Language Server + */ +@Singleton +public class TSLSLauncher extends LanguageServerLauncherTemplate { + private static final String[] EXTENSIONS = new String[] {Constants.TS_EXT}; + private static final String[] MIME_TYPES = new String[] {Constants.TS_MIME_TYPE}; + private static final LanguageDescriptionImpl description; + + private final Path launchScript; + + public TSLSLauncher() { + launchScript = Paths.get(System.getenv("HOME"), "che/ls-typescript/launch.sh"); + } + + @Override + protected Process startLanguageServerProcess(String projectPath) throws LanguageServerException { + ProcessBuilder processBuilder = new ProcessBuilder(launchScript.toString()); + processBuilder.redirectInput(ProcessBuilder.Redirect.PIPE); + processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE); + try { + return processBuilder.start(); + } catch (IOException e) { + throw new LanguageServerException("Can't start TypeScript language server", e); + } + } + + @Override + protected LanguageServer connectToLanguageServer(Process languageServerProcess) throws LanguageServerException { + JsonBasedLanguageServer languageServer = new JsonBasedLanguageServer(); + languageServer.connect(languageServerProcess.getInputStream(), languageServerProcess.getOutputStream()); + return languageServer; + } + + @Override + public LanguageDescription getLanguageDescription() { + return description; + } + + @Override + public boolean isAbleToLaunch() { + return Files.exists(launchScript); + } + + static { + description = new LanguageDescriptionImpl(); + description.setFileExtensions(asList(EXTENSIONS)); + description.setLanguageId(Constants.TS_LANG); + description.setMimeTypes(asList(MIME_TYPES)); + description.setHighlightingConfiguration("[\n" + + " {\"include\":\"orion.js\"},\n" + + " {\"match\":\"\\\\b(?:constructor|declare|module)\\\\b\",\"name\" :\"keyword.operator.typescript\"},\n" + + " {\"match\":\"\\\\b(?:any|boolean|number|string)\\\\b\",\"name\" : \"storage.type.typescript\"}\n" + + "]"); + } +} diff --git a/plugins/plugin-web/che-plugin-web-ext-server/src/main/java/org/eclipse/che/plugin/web/typescript/TypeScriptProjectType.java b/plugins/plugin-web/che-plugin-web-ext-server/src/main/java/org/eclipse/che/plugin/web/typescript/TypeScriptProjectType.java new file mode 100644 index 0000000000..4443c3fa46 --- /dev/null +++ b/plugins/plugin-web/che-plugin-web-ext-server/src/main/java/org/eclipse/che/plugin/web/typescript/TypeScriptProjectType.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.web.typescript; + +import org.eclipse.che.api.project.server.type.ProjectTypeDef; +import org.eclipse.che.plugin.web.shared.Constants; + +/** + * TypeScript project type definition + */ +public class TypeScriptProjectType extends ProjectTypeDef { + + public TypeScriptProjectType(){ + super(Constants.TS_PROJECT_TYPE_ID, "TypeScript project", true, false, true); + addConstantDefinition(Constants.LANGUAGE, "language", Constants.TS_LANG); + } +} diff --git a/plugins/plugin-web/che-plugin-web-ext-shared/pom.xml b/plugins/plugin-web/che-plugin-web-ext-shared/pom.xml new file mode 100644 index 0000000000..768a615c2d --- /dev/null +++ b/plugins/plugin-web/che-plugin-web-ext-shared/pom.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + + che-plugin-web-parent + org.eclipse.che.plugin + 5.0.0-M8-SNAPSHOT + + che-plugin-web-ext-shared + + src/main/java + target/classes + + + src/main/java + + + src/main/resources + + + + + src/test/resources + + + + diff --git a/plugins/plugin-web/che-plugin-web-ext-shared/src/main/java/org/eclipse/che/plugin/web/shared/Constants.java b/plugins/plugin-web/che-plugin-web-ext-shared/src/main/java/org/eclipse/che/plugin/web/shared/Constants.java new file mode 100644 index 0000000000..7cb928e8ec --- /dev/null +++ b/plugins/plugin-web/che-plugin-web-ext-shared/src/main/java/org/eclipse/che/plugin/web/shared/Constants.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.web.shared; + +/** + * Shared constants for Web plugin + */ +public final class Constants { + + public static final String LANGUAGE = "language"; + + /** TS Project Type ID */ + public static String TS_PROJECT_TYPE_ID = "typescript"; + + /** TS Language */ + public static String TS_LANG = "typescript"; + + /** Default extension for TS files */ + public static String TS_EXT = "ts"; + + /** TypeScript file mime type*/ + public static final String TS_MIME_TYPE = "application/typescript"; + + private Constants() { + } +} diff --git a/plugins/plugin-web/che-plugin-web-ext-shared/src/main/resources/org/eclipse/che/plugin/web/WebShared.gwt.xml b/plugins/plugin-web/che-plugin-web-ext-shared/src/main/resources/org/eclipse/che/plugin/web/WebShared.gwt.xml new file mode 100644 index 0000000000..961f109732 --- /dev/null +++ b/plugins/plugin-web/che-plugin-web-ext-shared/src/main/resources/org/eclipse/che/plugin/web/WebShared.gwt.xml @@ -0,0 +1,17 @@ + + + + + + diff --git a/plugins/plugin-web/che-plugin-web-ext-web/pom.xml b/plugins/plugin-web/che-plugin-web-ext-web/pom.xml index 221a13b361..f3fb7dcd37 100644 --- a/plugins/plugin-web/che-plugin-web-ext-web/pom.xml +++ b/plugins/plugin-web/che-plugin-web-ext-web/pom.xml @@ -37,6 +37,10 @@ org.eclipse.che.core che-core-ide-api + + org.eclipse.che.plugin + che-plugin-web-ext-shared + com.google.gwt gwt-elemental diff --git a/plugins/plugin-web/che-plugin-web-ext-web/src/main/java/org/eclipse/che/ide/ext/web/WebExtension.java b/plugins/plugin-web/che-plugin-web-ext-web/src/main/java/org/eclipse/che/ide/ext/web/WebExtension.java index 45339ef629..e8c7ba292c 100644 --- a/plugins/plugin-web/che-plugin-web-ext-web/src/main/java/org/eclipse/che/ide/ext/web/WebExtension.java +++ b/plugins/plugin-web/che-plugin-web-ext-web/src/main/java/org/eclipse/che/ide/ext/web/WebExtension.java @@ -56,15 +56,13 @@ public class WebExtension { @Named("JSFileType") FileType jsFile, @Named("HTMLFileType") FileType htmlFile, @Named("ES6FileType") FileType es6File, - @Named("JSXFileType") FileType jsxFile, - @Named("TypeScript") FileType typeScriptFile) { + @Named("JSXFileType") FileType jsxFile) { // register new Icon for javascript project type iconRegistry.registerIcon(new Icon("JavaScript.samples.category.icon", resources.samplesCategoryJs())); editorRegistry.registerDefaultEditor(jsFile, jsEditorProvider); editorRegistry.registerDefaultEditor(es6File, jsEditorProvider); editorRegistry.registerDefaultEditor(jsxFile, jsEditorProvider); - editorRegistry.registerDefaultEditor(typeScriptFile, jsEditorProvider); editorRegistry.registerDefaultEditor(htmlFile, htmlEditorProvider); } diff --git a/plugins/plugin-web/che-plugin-web-ext-web/src/main/java/org/eclipse/che/ide/ext/web/inject/WebModule.java b/plugins/plugin-web/che-plugin-web-ext-web/src/main/java/org/eclipse/che/ide/ext/web/inject/WebModule.java index 27c501657a..579d165a1b 100644 --- a/plugins/plugin-web/che-plugin-web-ext-web/src/main/java/org/eclipse/che/ide/ext/web/inject/WebModule.java +++ b/plugins/plugin-web/che-plugin-web-ext-web/src/main/java/org/eclipse/che/ide/ext/web/inject/WebModule.java @@ -11,13 +11,16 @@ package org.eclipse.che.ide.ext.web.inject; import com.google.gwt.inject.client.AbstractGinModule; +import com.google.gwt.inject.client.multibindings.GinMultibinder; import com.google.inject.Provides; import com.google.inject.Singleton; import com.google.inject.name.Named; import org.eclipse.che.ide.api.extension.ExtensionGinModule; import org.eclipse.che.ide.api.filetypes.FileType; +import org.eclipse.che.ide.api.project.type.wizard.ProjectWizardRegistrar; import org.eclipse.che.ide.ext.web.WebExtensionResource; +import org.eclipse.che.ide.ext.web.typescript.TSProjectWizardRegistrar; /** * Adds custom binding for Editors. @@ -29,6 +32,7 @@ public class WebModule extends AbstractGinModule { @Override protected void configure() { + GinMultibinder.newSetBinder(binder(), ProjectWizardRegistrar.class).addBinding().to(TSProjectWizardRegistrar.class); } @Provides diff --git a/plugins/plugin-web/che-plugin-web-ext-web/src/main/java/org/eclipse/che/ide/ext/web/typescript/TSProjectWizardRegistrar.java b/plugins/plugin-web/che-plugin-web-ext-web/src/main/java/org/eclipse/che/ide/ext/web/typescript/TSProjectWizardRegistrar.java new file mode 100644 index 0000000000..f6fb6bc0e1 --- /dev/null +++ b/plugins/plugin-web/che-plugin-web-ext-web/src/main/java/org/eclipse/che/ide/ext/web/typescript/TSProjectWizardRegistrar.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.ide.ext.web.typescript; + +import com.google.inject.Provider; + +import org.eclipse.che.ide.api.project.MutableProjectConfig; +import org.eclipse.che.ide.api.project.type.wizard.ProjectWizardRegistrar; +import org.eclipse.che.ide.api.wizard.WizardPage; +import org.eclipse.che.plugin.web.shared.Constants; + +import java.util.ArrayList; +import java.util.List; + +/** + * Provides information for registering TypeScript project type into project wizard. + */ +public class TSProjectWizardRegistrar implements ProjectWizardRegistrar { + + private final List>> wizardPages; + + public TSProjectWizardRegistrar() { + wizardPages = new ArrayList<>(); + } + + @Override + public String getProjectTypeId() { + return Constants.TS_PROJECT_TYPE_ID; + } + + @Override + public String getCategory() { + return "TypeScript"; + } + + @Override + public List>> getWizardPages() { + return wizardPages; + } +} diff --git a/plugins/plugin-web/che-plugin-web-ext-web/src/main/resources/org/eclipse/che/ide/ext/web/Web.gwt.xml b/plugins/plugin-web/che-plugin-web-ext-web/src/main/resources/org/eclipse/che/ide/ext/web/Web.gwt.xml index 658e82fe89..24a4101883 100644 --- a/plugins/plugin-web/che-plugin-web-ext-web/src/main/resources/org/eclipse/che/ide/ext/web/Web.gwt.xml +++ b/plugins/plugin-web/che-plugin-web-ext-web/src/main/resources/org/eclipse/che/ide/ext/web/Web.gwt.xml @@ -16,6 +16,7 @@ + diff --git a/plugins/plugin-web/pom.xml b/plugins/plugin-web/pom.xml index e22061b61c..5718e2e37e 100644 --- a/plugins/plugin-web/pom.xml +++ b/plugins/plugin-web/pom.xml @@ -23,6 +23,8 @@ pom Che Plugin :: Web :: Parent + che-plugin-web-ext-shared che-plugin-web-ext-web + che-plugin-web-ext-server diff --git a/pom.xml b/pom.xml index 9cccfd1c04..c18dcdde70 100644 --- a/pom.xml +++ b/pom.xml @@ -776,6 +776,16 @@ che-plugin-svn-ext-shared ${che.version} + + org.eclipse.che.plugin + che-plugin-web-ext-server + ${che.version} + + + org.eclipse.che.plugin + che-plugin-web-ext-shared + ${che.version} + org.eclipse.che.plugin che-plugin-web-ext-web diff --git a/wsmaster/che-core-api-agent/src/main/resources/agents/org.eclipse.che.ls.typescript.json b/wsmaster/che-core-api-agent/src/main/resources/agents/org.eclipse.che.ls.typescript.json new file mode 100644 index 0000000000..a8922a5a8b --- /dev/null +++ b/wsmaster/che-core-api-agent/src/main/resources/agents/org.eclipse.che.ls.typescript.json @@ -0,0 +1,9 @@ +{ +"id": "org.eclipse.che.ls.js-ts", +"name": "TypeScript language server", +"description" : "TypeScript intellisense", +"dependencies": [], +"properties": { +}, +"script" : "#\n# Copyright (c) 2012-2016 Codenvy, S.A.\n# All rights reserved. This program and the accompanying materials\n# are made available under the terms of the Eclipse Public License v1.0\n# which accompanies this distribution, and is available at\n# http://www.eclipse.org/legal/epl-v10.html\n#\n# Contributors:\n# Codenvy, S.A. - initial API and implementation\n#\n\nunset PACKAGES\nunset SUDO\ncommand -v tar >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" tar\"; }\ncommand -v curl >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" curl\"; }\ntest \"$(id -u)\" = 0 || SUDO=\"sudo\"\n\nAGENT_BINARIES_URI=https://codenvy.com/update/repository/public/download/org.eclipse.che.ls.typescript.binaries\nCHE_DIR=$HOME/che\nLS_DIR=${CHE_DIR}/ls-typescript\nLS_LAUNCHER=${LS_DIR}/launch.sh\n\nif [ -f /etc/centos-release ]; then\n FILE=\"/etc/centos-release\"\n LINUX_TYPE=$(cat $FILE | awk '{print $1}')\n elif [ -f /etc/redhat-release ]; then\n FILE=\"/etc/redhat-release\"\n LINUX_TYPE=$(cat $FILE | cut -c 1-8)\n else\n FILE=\"/etc/os-release\"\n LINUX_TYPE=$(cat $FILE | grep ^ID= | tr '[:upper:]' '[:lower:]')\n LINUX_VERSION=$(cat $FILE | grep ^VERSION_ID=)\nfi\n\nMACHINE_TYPE=$(uname -m)\n\nmkdir -p ${CHE_DIR}\nmkdir -p ${LS_DIR}\n\n########################\n### Install packages ###\n########################\n\n# Red Hat Enterprise Linux 7\n############################\nif echo ${LINUX_TYPE} | grep -qi \"rhel\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;\n ${SUDO} yum -y install nodejs;\n }\n\n# Red Hat Enterprise Linux 6\n############################\nelif echo ${LINUX_TYPE} | grep -qi \"Red Hat\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;\n ${SUDO} yum -y install nodejs;\n }\n\n\n# Ubuntu 14.04 16.04 / Linux Mint 17\n####################################\nelif echo ${LINUX_TYPE} | grep -qi \"ubuntu\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} apt-get update;\n ${SUDO} apt-get -y install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n {\n if test \"${SUDO}\" = \"\"; then\n curl -sL https://deb.nodesource.com/setup_6.x | bash -;\n else\n curl -sL https://deb.nodesource.com/setup_6.x | ${SUDO} -E bash -;\n fi\n };\n\n ${SUDO} apt-get update;\n ${SUDO} apt-get install -y nodejs;\n }\n\n\n# Debian 8\n##########\nelif echo ${LINUX_TYPE} | grep -qi \"debian\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} apt-get update;\n ${SUDO} apt-get -y install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n {\n if test \"${SUDO}\" = \"\"; then\n curl -sL https://deb.nodesource.com/setup_6.x | bash -;\n else\n curl -sL https://deb.nodesource.com/setup_6.x | ${SUDO} -E bash -;\n fi\n };\n\n ${SUDO} apt-get update;\n ${SUDO} apt-get install -y nodejs;\n }\n\n# Fedora 23\n###########\nelif echo ${LINUX_TYPE} | grep -qi \"fedora\"; then\n PACKAGES=${PACKAGES}\" procps-ng\"\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} dnf -y install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;\n ${SUDO} dnf -y install nodejs;\n }\n\n\n# CentOS 7.1 & Oracle Linux 7.1\n###############################\nelif echo ${LINUX_TYPE} | grep -qi \"centos\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum -y install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;\n ${SUDO} yum -y install nodejs;\n }\n\n# openSUSE 13.2\n###############\nelif echo ${LINUX_TYPE} | grep -qi \"opensuse\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} zypper install -y ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n ${SUDO} zypper ar http://download.opensuse.org/repositories/devel:/languages:/nodejs/openSUSE_13.1/ Node.js\n ${SUDO} zypper in nodejs\n }\n\nelse\n >&2 echo \"Unrecognized Linux Type\"\n >&2 cat $FILE\n exit 1\nfi\n\n\n########################\n### Install JS-TS LS ###\n########################\n\ncurl -s ${AGENT_BINARIES_URI} | tar xzf - -C ${LS_DIR}\n\ntouch ${LS_LAUNCHER}\nchmod +x ${LS_LAUNCHER}\necho \"nodejs ${LS_DIR}/build/language-server-stdio.js\" > ${LS_LAUNCHER}" +} diff --git a/wsmaster/che-core-api-agent/src/main/resources/agents/scripts/org.eclipse.che.ls.typescript.script.sh b/wsmaster/che-core-api-agent/src/main/resources/agents/scripts/org.eclipse.che.ls.typescript.script.sh new file mode 100644 index 0000000000..b10165e979 --- /dev/null +++ b/wsmaster/che-core-api-agent/src/main/resources/agents/scripts/org.eclipse.che.ls.typescript.script.sh @@ -0,0 +1,165 @@ +# +# Copyright (c) 2012-2016 Codenvy, S.A. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Codenvy, S.A. - initial API and implementation +# + +unset PACKAGES +unset SUDO +command -v tar >/dev/null 2>&1 || { PACKAGES=${PACKAGES}" tar"; } +command -v curl >/dev/null 2>&1 || { PACKAGES=${PACKAGES}" curl"; } +test "$(id -u)" = 0 || SUDO="sudo" + +AGENT_BINARIES_URI=https://codenvy.com/update/repository/public/download/org.eclipse.che.ls.typescript.binaries +CHE_DIR=$HOME/che +LS_DIR=${CHE_DIR}/ls-typescript +LS_LAUNCHER=${LS_DIR}/launch.sh + +if [ -f /etc/centos-release ]; then + FILE="/etc/centos-release" + LINUX_TYPE=$(cat $FILE | awk '{print $1}') + elif [ -f /etc/redhat-release ]; then + FILE="/etc/redhat-release" + LINUX_TYPE=$(cat $FILE | cut -c 1-8) + else + FILE="/etc/os-release" + LINUX_TYPE=$(cat $FILE | grep ^ID= | tr '[:upper:]' '[:lower:]') + LINUX_VERSION=$(cat $FILE | grep ^VERSION_ID=) +fi + +MACHINE_TYPE=$(uname -m) + +mkdir -p ${CHE_DIR} +mkdir -p ${LS_DIR} + +######################## +### Install packages ### +######################## + +# Red Hat Enterprise Linux 7 +############################ +if echo ${LINUX_TYPE} | grep -qi "rhel"; then + test "${PACKAGES}" = "" || { + ${SUDO} yum install ${PACKAGES}; + } + + command -v nodejs >/dev/null 2>&1 || { + curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -; + ${SUDO} yum -y install nodejs; + } + +# Red Hat Enterprise Linux 6 +############################ +elif echo ${LINUX_TYPE} | grep -qi "Red Hat"; then + test "${PACKAGES}" = "" || { + ${SUDO} yum install ${PACKAGES}; + } + + command -v nodejs >/dev/null 2>&1 || { + curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -; + ${SUDO} yum -y install nodejs; + } + + +# Ubuntu 14.04 16.04 / Linux Mint 17 +#################################### +elif echo ${LINUX_TYPE} | grep -qi "ubuntu"; then + test "${PACKAGES}" = "" || { + ${SUDO} apt-get update; + ${SUDO} apt-get -y install ${PACKAGES}; + } + + command -v nodejs >/dev/null 2>&1 || { + { + if test "${SUDO}" = ""; then + curl -sL https://deb.nodesource.com/setup_6.x | bash -; + else + curl -sL https://deb.nodesource.com/setup_6.x | ${SUDO} -E bash -; + fi + }; + + ${SUDO} apt-get update; + ${SUDO} apt-get install -y nodejs; + } + + +# Debian 8 +########## +elif echo ${LINUX_TYPE} | grep -qi "debian"; then + test "${PACKAGES}" = "" || { + ${SUDO} apt-get update; + ${SUDO} apt-get -y install ${PACKAGES}; + } + + command -v nodejs >/dev/null 2>&1 || { + { + if test "${SUDO}" = ""; then + curl -sL https://deb.nodesource.com/setup_6.x | bash -; + else + curl -sL https://deb.nodesource.com/setup_6.x | ${SUDO} -E bash -; + fi + }; + + ${SUDO} apt-get update; + ${SUDO} apt-get install -y nodejs; + } + +# Fedora 23 +########### +elif echo ${LINUX_TYPE} | grep -qi "fedora"; then + PACKAGES=${PACKAGES}" procps-ng" + test "${PACKAGES}" = "" || { + ${SUDO} dnf -y install ${PACKAGES}; + } + + command -v nodejs >/dev/null 2>&1 || { + curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -; + ${SUDO} dnf -y install nodejs; + } + + +# CentOS 7.1 & Oracle Linux 7.1 +############################### +elif echo ${LINUX_TYPE} | grep -qi "centos"; then + test "${PACKAGES}" = "" || { + ${SUDO} yum -y install ${PACKAGES}; + } + + command -v nodejs >/dev/null 2>&1 || { + curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -; + ${SUDO} yum -y install nodejs; + } + +# openSUSE 13.2 +############### +elif echo ${LINUX_TYPE} | grep -qi "opensuse"; then + test "${PACKAGES}" = "" || { + ${SUDO} zypper install -y ${PACKAGES}; + } + + command -v nodejs >/dev/null 2>&1 || { + ${SUDO} zypper ar http://download.opensuse.org/repositories/devel:/languages:/nodejs/openSUSE_13.1/ Node.js + ${SUDO} zypper in nodejs + } + +else + >&2 echo "Unrecognized Linux Type" + >&2 cat $FILE + exit 1 +fi + + +######################## +### Install JS-TS LS ### +######################## + +curl -s ${AGENT_BINARIES_URI} | tar xzf - -C ${LS_DIR} + +touch ${LS_LAUNCHER} +chmod +x ${LS_LAUNCHER} +echo "nodejs ${LS_DIR}/build/language-server-stdio.js" > ${LS_LAUNCHER} diff --git a/wsmaster/che-core-api-agent/src/main/resources/agents/scripts/update_agents.sh b/wsmaster/che-core-api-agent/src/main/resources/agents/scripts/update_agents.sh index edafe2859e..ee36ba12ba 100755 --- a/wsmaster/che-core-api-agent/src/main/resources/agents/scripts/update_agents.sh +++ b/wsmaster/che-core-api-agent/src/main/resources/agents/scripts/update_agents.sh @@ -35,3 +35,4 @@ updateAgentScript ".." "org.eclipse.che.ls.json" updateAgentScript ".." "org.eclipse.che.ls.csharp" updateAgentScript ".." "org.eclipse.che.ls.php" updateAgentScript ".." "org.eclipse.che.unison" +updateAgentScript ".." "org.eclipse.che.ls.typescript"