diff --git a/develop.md b/develop.md new file mode 100644 index 0000000..2e9a53f --- /dev/null +++ b/develop.md @@ -0,0 +1,69 @@ +Development notes +================= + +Working on this package +----------------------- + +### General tips + +- Install dependencies with `npm install` +- Remove the installed package from `~/.atom/packages` if exists +- Create a symlink to this Git clone in `~/.atom/packages` +- Have two windows open, one for dev and one for reloading +- To try the changes, reload the dev window with `window:reload` command (`control shift F5` in Linux) +- See also: http://flight-manual.atom.io/hacking-atom/sections/debugging/ + +Hacking atom-languageclient +--------------------------- + +Replace `node_modules/atom-languageclient` with your Git clone. + +To try the changes in Atom, run `npm install`, and reload the dev window. + +Run the tests with `npm run test`. + +The upstream GitHub project (to contribute changes) is at `atom/atom-languageclient`. + +You can enable debug logs with: + + atom.config.set('core.debugLSP', true) + +Packaging, publishing +--------------------- + +### Build + + npm install + +### Execute tests + + atom --test spec + +### Test installation from personal repo + + apm install gh-user/repo + +### Publish + +Verify `package.json` content, especially version. + + apm publish minor + +See also: http://flight-manual.atom.io/hacking-atom/sections/publishing/ + +Misc +---- + +### Lifecycle of a package + +This document explains nicely the steps performed during the startup of a package: + +http://flight-manual.atom.io/hacking-atom/sections/package-word-count/ + +### Generate clean new package + +It can be helpful sometimes to start clean. + +- Generate package using command (`control shift p`) + - Creates a folder with basic files + - Registers the folder in ~/.atom/packages diff --git a/lib/files.js b/lib/files.js index 3cc11dd..52b49dc 100644 --- a/lib/files.js +++ b/lib/files.js @@ -9,7 +9,7 @@ const path = require('path'); const languageServerInfo = { basedir: 'files/server', - url: "https://repox.sonarsource.com/sonarsource-public-releases/org/sonarsource/sonarlint/core/sonarlint-language-server/2.15.0.797/sonarlint-language-server-2.15.0.797.jar", + url: "https://repox.sonarsource.com/sonarsource-public-builds/org/sonarsource/sonarlint/core/sonarlint-language-server/2.15.0.814/sonarlint-language-server-2.15.0.814.jar", filename: "sonarlint-ls.jar" } const analyzerBasedir = 'files/analyzers' diff --git a/lib/requirements.js b/lib/requirements.js index 1e62cf2..ecdde41 100644 --- a/lib/requirements.js +++ b/lib/requirements.js @@ -14,6 +14,7 @@ const expandHomeDir = require('expand-home-dir'); const findJavaHome = require('find-java-home'); const JAVA_BINARY = 'java' + ((process.platform.indexOf('win') === 0) ? '.exe' : ''); +const javaHomeSettingName = 'sonarlint.javaHome' exports.java = JAVA_BINARY; @@ -27,7 +28,7 @@ function checkJavaRuntime() { let source; let javaHome = readJavaConfig(); if (javaHome) { - source = "The 'sonarlint.ls.javaHome' variable defined in settings"; + source = `The '${javaHomeSettingName}' configuration defined in settings`; } else { javaHome = process.env['JDK_HOME']; if (javaHome) { @@ -40,17 +41,17 @@ function checkJavaRuntime() { if (javaHome) { javaHome = expandHomeDir(javaHome); if (!pathExists.sync(javaHome)) { - openJREDownload(reject, source + ' points to a missing folder'); + openJREDownload(reject, `${source} points to a non-existent folder: ${javaHome}`); } if (!pathExists.sync(path.resolve(javaHome, 'bin', JAVA_BINARY))){ - openJREDownload(reject, source + ' does not point to a JRE.'); + openJREDownload(reject, `${source} does not point to a JRE.`); } return resolve(javaHome); } //No settings, let's try to detect as last resort. findJavaHome(function (err, home) { if (err) { - openJREDownload(reject, "Java runtime could not be located. Install it and set its location using 'sonarlint.ls.javaHome' variable in settings."); + openJREDownload(reject, `Java runtime could not be located. Install it and set its location using '${javaHomeSettingName}' in settings.`); } else { resolve(home); } @@ -59,16 +60,12 @@ function checkJavaRuntime() { } function readJavaConfig() { - return atom.config.get('sonarlint.ls.javaHome'); + return atom.config.get(javaHomeSettingName); } function checkJavaVersion(javaHome) { return new Promise((resolve, reject) => { const prog = path.resolve(javaHome, 'bin', JAVA_BINARY); - if ((fs.statSync(prog).mode & 1) == 0) { - openJREDownload(reject, "Java binary not an executable file: " + prog); - return; - } cp.execFile(prog, ['-version'], {}, (error, stdout, stderr) => { if (stderr.indexOf('version "9') > -1) { diff --git a/package.json b/package.json index 4b83079..f188dac 100644 --- a/package.json +++ b/package.json @@ -37,13 +37,17 @@ "files" ], "dependencies": { - "atom-languageclient": "SonarSource/atom-languageclient#f1a0372e163191213edeefa13c8d3f8e7cf7a367", + "atom-languageclient": "SonarSource/atom-languageclient#43a843f5fa80b909b9a80d88409bfb92ad94350a", "atom-linter": "^10.0.0", "expand-home-dir": "0.0.3", - "find-java-home": "^0.1.4" + "find-java-home": "^0.1.4", + "path-exists": "^3.0.0" }, "bundledDependencies": [ - "atom-languageclient" + "atom-languageclient", + "expand-home-dir", + "find-java-home", + "path-exists" ], "scripts": { "prepublish": "node ./scripts/setup.js" @@ -64,6 +68,11 @@ "gulp-zip": "^4.0.0" }, "configSchema": { + "javaHome": { + "type": "string", + "default": "", + "order": 1 + }, "testFilePattern": { "type": "string", "default": "{**/test/**,**/*test*,**/*Test*}",