From 9f771e839ff611761a7f0badc6fa9687f9966d80 Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Thu, 6 Oct 2016 08:28:43 -0700 Subject: [PATCH] api updates --- app/auto-updater.js | 2 +- app/config.js | 17 ++++++++++++++--- app/package.json | 8 ++++---- app/plugins.js | 24 ++++++++++++------------ app/session.js | 2 +- lib/actions/ui.js | 4 ++-- lib/components/notifications.js | 2 +- package.json | 6 +++--- 8 files changed, 38 insertions(+), 27 deletions(-) diff --git a/app/auto-updater.js b/app/auto-updater.js index a1702e6b..fd4aa95d 100644 --- a/app/auto-updater.js +++ b/app/auto-updater.js @@ -9,7 +9,7 @@ const {version} = require('./package'); const platform = process.platform === 'darwin' ? 'osx' : process.platform; -const FEED_URL = `https://hyperterm-updates.now.sh/update/${platform}`; +const FEED_URL = `https://hyper-updates.now.sh/update/${platform}`; let isInit = false; function init() { diff --git a/app/config.js b/app/config.js index 27a0d2ea..f9d30939 100644 --- a/app/config.js +++ b/app/config.js @@ -1,5 +1,5 @@ const {homedir} = require('os'); -const {readFileSync, writeFileSync} = require('fs'); +const {statSync, renameSync, readFileSync, writeFileSync} = require('fs'); const {resolve} = require('path'); const vm = require('vm'); @@ -16,7 +16,8 @@ const winCfg = new Config({ } }); -const path = resolve(homedir(), '.hyperterm.js'); +const path = resolve(homedir(), '.hyper.js'); +const pathLegacy = resolve(homedir(), '.hyperterm.js'); const watchers = []; let cfg = {}; @@ -29,7 +30,7 @@ function watch() { this.on('changed', () => { try { if (exec(readFileSync(path, 'utf8'))) { - notify('HyperTerm configuration reloaded!'); + notify('Hyper configuration reloaded!'); watchers.forEach(fn => fn()); } } catch (err) { @@ -72,6 +73,16 @@ exports.subscribe = function (fn) { }; exports.init = function () { + // for backwards compatibility with hyperterm + // (prior to the renme), we try to rename + // on behalf of the user + try { + const stat = statSync(pathLegacy); + renameSync(pathLegacy, path); + } catch (err) { + // ignore + } + try { exec(readFileSync(path, 'utf8')); } catch (err) { diff --git a/app/package.json b/app/package.json index 7f02def0..d379700e 100644 --- a/app/package.json +++ b/app/package.json @@ -1,13 +1,13 @@ { - "name": "hyperterm", - "productName": "HyperTerm", - "version": "0.8.0", + "name": "hyper", + "productName": "Hyper", + "version": "0.8.1", "license": "MIT", "author": { "name": "Zeit, Inc.", "email": "team@zeit.co" }, - "repository": "zeit/hyperterm", + "repository": "zeit/hyper", "description": "HTML/JS/CSS Terminal", "dependencies": { "child_pty": "3.0.1", diff --git a/app/plugins.js b/app/plugins.js index 89008d89..fa7bd2c2 100644 --- a/app/plugins.js +++ b/app/plugins.js @@ -16,8 +16,8 @@ const notify = require('./notify'); const cache = new Config(); // modules path -const path = resolve(homedir(), '.hyperterm_plugins'); -const localPath = resolve(homedir(), '.hyperterm_plugins', 'local'); +const path = resolve(homedir(), '.hyper_plugins'); +const localPath = resolve(homedir(), '.hyper_plugins', 'local'); const availableExtensions = new Set([ 'onApp', 'onWindow', 'onUnload', 'middleware', 'reduceUI', 'reduceSessions', 'decorateMenu', @@ -78,12 +78,12 @@ function updatePlugins({force = false} = {}) { } else { notify( 'Error updating plugins.', - 'Check `~/.hyperterm_plugins/npm-debug.log` for more information.' + 'Check `~/.hyper_plugins/npm-debug.log` for more information.' ); } } else { // flag successful plugin update - cache.set('hyperterm.plugins', id_); + cache.set('hyper.plugins', id_); // cache paths paths = getPaths(plugins); @@ -97,8 +97,8 @@ function updatePlugins({force = false} = {}) { const loaded = modules.length; const total = paths.plugins.length + paths.localPlugins.length; const pluginVersions = JSON.stringify(getPluginVersions()); - const changed = cache.get('hyperterm.plugin-versions') !== pluginVersions && loaded === total; - cache.set('hyperterm.plugin-versions', pluginVersions); + const changed = cache.get('hyper.plugin-versions') !== pluginVersions && loaded === total; + cache.set('hyper.plugin-versions', pluginVersions); // notify watchers if (force || changed) { @@ -154,7 +154,7 @@ exports.updatePlugins = updatePlugins; // we schedule the initial plugins update // a bit after the user launches the terminal // to prevent slowness -if (cache.get('hyperterm.plugins') !== id || process.env.HYPERTERM_FORCE_UPDATE) { +if (cache.get('hyper.plugins') !== id || process.env.HYPER_FORCE_UPDATE) { // install immediately if the user changed plugins console.log('plugins have changed / not init, scheduling plugins installation'); setTimeout(() => { @@ -168,13 +168,13 @@ setInterval(updatePlugins, ms('5h')); function syncPackageJSON() { const dependencies = toDependencies(plugins); const pkg = { - name: 'hyperterm-plugins', - description: 'Auto-generated from `~/.hyperterm.js`!', + name: 'hyper-plugins', + description: 'Auto-generated from `~/.hyper.js`!', private: true, version: '0.0.1', - repository: 'zeit/hyperterm', + repository: 'zeit/hyper', license: 'MIT', - homepage: 'https://hyperterm.org', + homepage: 'https://hyper.is', dependencies }; @@ -276,7 +276,7 @@ function requirePlugins() { const exposed = mod && Object.keys(mod).some(key => availableExtensions.has(key)); if (!exposed) { notify('Plugin error!', `Plugin "${basename(path)}" does not expose any ` + - 'HyperTerm extension API methods'); + 'Hyper extension API methods'); return; } diff --git a/app/session.js b/app/session.js index 27ff33bc..41cac284 100644 --- a/app/session.js +++ b/app/session.js @@ -17,7 +17,7 @@ try { 'A native module failed to load. Typically this means ' + 'you installed the modules incorrectly.\n Use `scripts/install.sh` ' + 'to trigger the installation.\n ' + - 'More information: https://github.com/zeit/hyperterm/issues/72' + 'More information: https://github.com/zeit/hyper/issues/72' ); } diff --git a/lib/actions/ui.js b/lib/actions/ui.js index b2370828..74471e86 100644 --- a/lib/actions/ui.js +++ b/lib/actions/ui.js @@ -213,9 +213,9 @@ export function showPreferences() { dispatch(sendSessionData( uid, // Leading space prevents command to be store in shell history - [' echo Attempting to open ~/.hyperterm.js with your \$EDITOR', // eslint-disable-line no-useless-escape + [' echo Attempting to open ~/.hyper.js with your \$EDITOR', // eslint-disable-line no-useless-escape ' echo If it fails, open it manually with your favorite editor!', - ' bash -c \'exec env ${EDITOR:=' + editorFallback + '} ~/.hyperterm.js\'', + ' bash -c \'exec env ${EDITOR:=' + editorFallback + '} ~/.hyper.js\'', '' ].join('\n') )); diff --git a/lib/components/notifications.js b/lib/components/notifications.js index 1a227c66..75a0b12a 100644 --- a/lib/components/notifications.js +++ b/lib/components/notifications.js @@ -82,7 +82,7 @@ export default class Notifications extends Component { window.require('electron').shell.openExternal(ev.target.href); ev.preventDefault(); }} - href={`https://github.com/zeit/hyperterm/releases/tag/${this.props.updateVersion}`} + href={`https://github.com/zeit/hyper/releases/tag/${this.props.updateVersion}`} >notes). {' '}