diff --git a/lib/julia-client.coffee b/lib/julia-client.coffee deleted file mode 100644 index f8149645..00000000 --- a/lib/julia-client.coffee +++ /dev/null @@ -1,150 +0,0 @@ -etch = require 'etch' - -commands = require './package/commands' -config = require './package/config' -menu = require './package/menu' -settings = require './package/settings' -release = require './package/release-note' -toolbar = require './package/toolbar' -semver = require 'semver' - -# TODO: Update me when tagging a new relase (and release note) -INK_VERSION_COMPAT = "^0.12.4" -LATEST_RELEASE_NOTE_VERSION = "0.12.5" - -INK_LINK = '[`ink`](https://github.com/JunoLab/atom-ink)' -LANGUAGE_JULIA_LINK = '[`language-julia`](https://github.com/JuliaEditorSupport/atom-language-julia)' - -module.exports = JuliaClient = - misc: require './misc' - ui: require './ui' - connection: require './connection' - runtime: require './runtime' - - activate: (state) -> - etch.setScheduler(atom.views) - process.env['TERM'] = 'xterm-256color' - commands.activate @ - x.activate() for x in [menu, @connection, @runtime] - @ui.activate @connection.client - - @requireDeps => - settings.updateSettings() - - if atom.config.get('julia-client.firstBoot') - @ui.layout.queryDefaultLayout() - else - if atom.config.get('julia-client.uiOptions.layouts.openDefaultPanesOnStartUp') - setTimeout (=> @ui.layout.restoreDefaultLayout()), 150 - - requireDeps: (fn) -> - isLoaded = atom.packages.isPackageLoaded("ink") and atom.packages.isPackageLoaded("language-julia") - - if isLoaded - fn() - else - require('atom-package-deps').install('julia-client') - .then => @enableDeps fn - .catch (err) -> - console.error err - atom.notifications.addError 'Installing Juno\'s dependencies failed.', - description: - """ - Juno requires the packages #{INK_LINK} and #{LANGUAGE_JULIA_LINK} to run. - Please install them manually via `File -> Settings -> Packages`, - or open a terminal and run - - apm install ink - apm install language-julia - - and then restart Atom. - """ - dismissable: true - - enableDeps: (fn) -> - isEnabled = atom.packages.isPackageLoaded("ink") and atom.packages.isPackageLoaded("language-julia") - - if isEnabled - fn() - else - atom.packages.enablePackage('ink') - atom.packages.enablePackage('language-julia') - - if atom.packages.isPackageLoaded("ink") and atom.packages.isPackageLoaded("language-julia") - atom.notifications.addSuccess "Automatically enabled Juno's dependencies.", - description: - """ - Juno requires the #{INK_LINK} and #{LANGUAGE_JULIA_LINK} packages. - We've automatically enabled them for you. - """ - dismissable: true - - inkVersion = atom.packages.loadedPackages["ink"].metadata.version - if not atom.devMode and not semver.satisfies(inkVersion, INK_VERSION_COMPAT) - atom.notifications.addWarning "Potentially incompatible `ink` version detected.", - description: - """ - Please make sure to upgrade #{INK_LINK} to a version compatible with `#{INK_VERSION_COMPAT}`. - The currently installed version is `#{inkVersion}`. - - If you cannot install an appropriate version via via `File -> Settings -> Packages`, - open a terminal and run - - apm install ink@x.y.z - - where `x.y.z` is satisfies `#{INK_VERSION_COMPAT}`. - """ - dismissable: true - - fn() - else - atom.notifications.addError "Failed to enable Juno's dependencies.", - description: - """ - Juno requires the #{INK_LINK} and #{LANGUAGE_JULIA_LINK} packages. - Please install them manually via `File -> Settings -> Packages`, - or open a terminal and run - - apm install ink - apm install language-julia - - and then restart Atom. - """ - dismissable: true - - config: config - - deactivate: -> - x.deactivate() for x in [commands, menu, toolbar, release, @connection, @runtime, @ui] - - consumeInk: (ink) -> - commands.ink = ink - x.consumeInk ink for x in [@connection, @runtime, @ui] - try - v = atom.config.get('julia-client.currentVersion') - if v isnt LATEST_RELEASE_NOTE_VERSION - release.activate(ink, LATEST_RELEASE_NOTE_VERSION) - else - release.activate(ink) - catch err - console.log(err) - finally - atom.config.set('julia-client.currentVersion', LATEST_RELEASE_NOTE_VERSION) - - consumeStatusBar: (bar) -> @runtime.consumeStatusBar bar - - consumeToolBar: (bar) -> toolbar.consumeToolBar bar - - consumeGetServerConfig: (conf) -> @connection.consumeGetServerConfig(conf) - - consumeGetServerName: (name) -> @connection.consumeGetServerName(name) - - consumeDatatip: (datatipService) -> @runtime.consumeDatatip datatipService - - provideClient: -> @connection.client - - provideAutoComplete: -> @runtime.provideAutoComplete() - - provideHyperclick: -> @runtime.provideHyperclick() - - handleURI: (parsedURI) -> @runtime.handleURI parsedURI diff --git a/lib/julia-client.js b/lib/julia-client.js new file mode 100644 index 00000000..a6ccef32 --- /dev/null +++ b/lib/julia-client.js @@ -0,0 +1,198 @@ +'use babel' + +import etch from 'etch'; +import commands from './package/commands'; +import config from './package/config'; +import menu from './package/menu'; +import * as settings from './package/settings'; +import * as release from './package/release-note'; +import toolbar from './package/toolbar'; + +// TODO: Update me when tagging a new relase (and release note) +const INK_VERSION_COMPAT = "^0.12.4"; +const LATEST_RELEASE_NOTE_VERSION = "0.12.5"; + +const INK_LINK = '[`ink`](https://github.com/JunoLab/atom-ink)'; +const LANGUAGE_JULIA_LINK = '[`language-julia`](https://github.com/JuliaEditorSupport/atom-language-julia)'; + +import * as misc from './misc' +import * as ui from './ui' +import * as connection from './connection' +import * as runtime from './runtime' + +const JuliaClient = { + // TODO remove these from the export default and export them directly (prevents expensive copy) + // TODO don't use this.message use message directly (prevents expensive copy) + misc: misc, + ui: ui, + connection: connection, + runtime: runtime, + + activate(state) { + etch.setScheduler(atom.views); + process.env['TERM'] = 'xterm-256color'; + commands.activate(this); + for (let x of [menu, this.connection, this.runtime]) { + x.activate(); + } + this.ui.activate(this.connection.client); + + this.requireDeps(() => { + settings.updateSettings(); + + if (atom.config.get('julia-client.firstBoot')) { + this.ui.layout.queryDefaultLayout(); + } else { + if (atom.config.get('julia-client.uiOptions.layouts.openDefaultPanesOnStartUp')) { + setTimeout((() => this.ui.layout.restoreDefaultLayout()), 150); + } + } + }); + }, + + requireDeps(fn) { + const isLoaded = atom.packages.isPackageLoaded("ink") && atom.packages.isPackageLoaded("language-julia"); + + if (isLoaded) { + fn(); + } else { + require('atom-package-deps').install('julia-client') + .then(() => this.enableDeps(fn)) + .catch(function (err) { + console.error(err); + atom.notifications.addError('Installing Juno\'s dependencies failed.', { + description: + `Juno requires the packages ${INK_LINK} and ${LANGUAGE_JULIA_LINK} to run. + Please install them manually via \`File -> Settings -> Packages\`, + or open a terminal and run + + apm install ink + apm install language-julia + + and then restart Atom.`, + dismissable: true + } + ); + }); + } + }, + + enableDeps(fn) { + const isEnabled = atom.packages.isPackageLoaded("ink") && atom.packages.isPackageLoaded("language-julia"); + + if (isEnabled) { + fn(); + } else { + atom.packages.enablePackage('ink'); + atom.packages.enablePackage('language-julia'); + + if (atom.packages.isPackageLoaded("ink") && atom.packages.isPackageLoaded("language-julia")) { + atom.notifications.addSuccess("Automatically enabled Juno's dependencies.", { + description: + `Juno requires the ${INK_LINK} and ${LANGUAGE_JULIA_LINK} packages. + We've automatically enabled them for you.`, + dismissable: true + } + ); + + const inkVersion = atom.packages.loadedPackages["ink"].metadata.version; + const semverSatisfies = require('semver/functions/satisfies'); + if (!atom.devMode && !semverSatisfies(inkVersion, INK_VERSION_COMPAT)) { + atom.notifications.addWarning("Potentially incompatible `ink` version detected.", { + description: + `Please make sure to upgrade ${INK_LINK} to a version compatible with \`${INK_VERSION_COMPAT}\`. + The currently installed version is \`${inkVersion}\`. + + If you cannot install an appropriate version via via \`File -> Settings -> Packages\`, + open a terminal and run + + apm install ink@x.y.z + + where \`x.y.z\` is satisfies \`${INK_VERSION_COMPAT}\`.`, + dismissable: true + } + ); + } + + fn(); + } else { + atom.notifications.addError("Failed to enable Juno's dependencies.", { + description: + `Juno requires the ${INK_LINK} and ${LANGUAGE_JULIA_LINK} packages. + Please install them manually via \`File -> Settings -> Packages\`, + or open a terminal and run + + apm install ink + apm install language-julia + + and then restart Atom.`, + dismissable: true + } + ); + } + } + }, + + config, + + deactivate() { + [commands, menu, toolbar, release, this.connection, this.runtime, this.ui].map((x) => x.deactivate()); + }, + + consumeInk(ink) { + commands.ink = ink; + for (let x of [this.connection, this.runtime, this.ui]) { + x.consumeInk(ink); + } + try { + const v = atom.config.get('julia-client.currentVersion'); + if (v !== LATEST_RELEASE_NOTE_VERSION) { + release.activate(ink, LATEST_RELEASE_NOTE_VERSION); + } else { + release.activate(ink); + } + } catch (err) { + console.log(err); + } finally { + atom.config.set('julia-client.currentVersion', LATEST_RELEASE_NOTE_VERSION); + } + }, + + consumeStatusBar(bar) { + this.runtime.consumeStatusBar(bar); + }, + + consumeToolBar(bar) { + toolbar.consumeToolBar(bar); + }, + + consumeGetServerConfig(conf) { + this.connection.consumeGetServerConfig(conf); + }, + + consumeGetServerName(name) { + this.connection.consumeGetServerName(name); + }, + + consumeDatatip(datatipService) { + this.runtime.consumeDatatip(datatipService); + }, + + provideClient() { + return this.connection.client; + }, + + provideAutoComplete() { + return this.runtime.provideAutoComplete(); + }, + + provideHyperclick() { + return this.runtime.provideHyperclick(); + }, + + handleURI(parsedURI) { + this.runtime.handleURI(parsedURI); + } +}; + +export default JuliaClient; diff --git a/package-lock.json b/package-lock.json index 863d9376..f0c73b21 100644 --- a/package-lock.json +++ b/package-lock.json @@ -475,9 +475,9 @@ "integrity": "sha1-QnelR1RIiqlnXYhuNU24lMm9yYE=" }, "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==" }, "set-blocking": { "version": "2.0.0", diff --git a/package.json b/package.json index fea6d52d..ba849794 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "node-pty-prebuilt-multiarch": "0.9.0", "object-hash": "^2.0.3", "physical-cpu-count": "*", - "semver": "^6.3.0", + "semver": "^7.3.2", "ssh2": "^0.8.4", "underscore-plus": "*" },