add TypeScript language server (#3145)

* #3119 add TypeScript language server
Signed-off-by: Evgen Vidolob <evidolob@codenvy.com>
6.19.x
Evgen Vidolob 2016-12-08 16:38:40 +02:00 committed by GitHub
parent ab9b0946ec
commit b48fe2ddf5
19 changed files with 585 additions and 3 deletions

View File

@ -228,6 +228,14 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-zend-debugger-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-web-ext-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-web-ext-shared</artifactId>
</dependency>
<dependency>
<groupId>org.everrest</groupId>
<artifactId>everrest-core</artifactId>

View File

@ -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"
]
}
]

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-plugin-web-parent</artifactId>
<groupId>org.eclipse.che.plugin</groupId>
<version>5.0.0-M8-SNAPSHOT</version>
</parent>
<artifactId>che-plugin-web-ext-server</artifactId>
<dependencies>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-multibindings</artifactId>
</dependency>
<dependency>
<groupId>io.typefox.lsapi</groupId>
<artifactId>io.typefox.lsapi.services</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-languageserver</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-languageserver-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-inject</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-web-ext-shared</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -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<ProjectTypeDef> projectTypeMultibinder = Multibinder.newSetBinder(binder(), ProjectTypeDef.class);
projectTypeMultibinder.addBinding().to(TypeScriptProjectType.class);
Multibinder.newSetBinder(binder(), LanguageServerLauncher.class).addBinding().to(TSLSLauncher.class);
}
}

View File

@ -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" +
"]");
}
}

View File

@ -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);
}
}

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-plugin-web-parent</artifactId>
<groupId>org.eclipse.che.plugin</groupId>
<version>5.0.0-M8-SNAPSHOT</version>
</parent>
<artifactId>che-plugin-web-ext-shared</artifactId>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<outputDirectory>target/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
</build>
</project>

View File

@ -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() {
}
}

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN" "http://gwtproject.org/doctype/2.7.0/gwt-module.dtd">
<module>
<source path="shared"/>
</module>

View File

@ -37,6 +37,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-ide-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-web-ext-shared</artifactId>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-elemental</artifactId>

View File

@ -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);
}

View File

@ -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

View File

@ -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<Provider<? extends WizardPage<MutableProjectConfig>>> 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<Provider<? extends WizardPage<MutableProjectConfig>>> getWizardPages() {
return wizardPages;
}
}

View File

@ -16,6 +16,7 @@
<inherits name="org.eclipse.che.ide.Api"/>
<inherits name="org.eclipse.che.ide.Core"/>
<inherits name="org.eclipse.che.ide.Api"/>
<inherits name="org.eclipse.che.plugin.web.WebShared"/>
<source path=""/>
</module>

View File

@ -23,6 +23,8 @@
<packaging>pom</packaging>
<name>Che Plugin :: Web :: Parent</name>
<modules>
<module>che-plugin-web-ext-shared</module>
<module>che-plugin-web-ext-web</module>
<module>che-plugin-web-ext-server</module>
</modules>
</project>

10
pom.xml
View File

@ -776,6 +776,16 @@
<artifactId>che-plugin-svn-ext-shared</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-web-ext-server</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-web-ext-shared</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-web-ext-web</artifactId>

View File

@ -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}"
}

View File

@ -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}

View File

@ -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"