api updates

This commit is contained in:
Guillermo Rauch 2016-10-06 08:28:43 -07:00
parent 36c55a6580
commit 9f771e839f
8 changed files with 38 additions and 27 deletions

View file

@ -9,7 +9,7 @@ const {version} = require('./package');
const platform = process.platform === 'darwin' ? const platform = process.platform === 'darwin' ?
'osx' : 'osx' :
process.platform; 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; let isInit = false;
function init() { function init() {

View file

@ -1,5 +1,5 @@
const {homedir} = require('os'); const {homedir} = require('os');
const {readFileSync, writeFileSync} = require('fs'); const {statSync, renameSync, readFileSync, writeFileSync} = require('fs');
const {resolve} = require('path'); const {resolve} = require('path');
const vm = require('vm'); 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 = []; const watchers = [];
let cfg = {}; let cfg = {};
@ -29,7 +30,7 @@ function watch() {
this.on('changed', () => { this.on('changed', () => {
try { try {
if (exec(readFileSync(path, 'utf8'))) { if (exec(readFileSync(path, 'utf8'))) {
notify('HyperTerm configuration reloaded!'); notify('Hyper configuration reloaded!');
watchers.forEach(fn => fn()); watchers.forEach(fn => fn());
} }
} catch (err) { } catch (err) {
@ -72,6 +73,16 @@ exports.subscribe = function (fn) {
}; };
exports.init = function () { 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 { try {
exec(readFileSync(path, 'utf8')); exec(readFileSync(path, 'utf8'));
} catch (err) { } catch (err) {

View file

@ -1,13 +1,13 @@
{ {
"name": "hyperterm", "name": "hyper",
"productName": "HyperTerm", "productName": "Hyper",
"version": "0.8.0", "version": "0.8.1",
"license": "MIT", "license": "MIT",
"author": { "author": {
"name": "Zeit, Inc.", "name": "Zeit, Inc.",
"email": "team@zeit.co" "email": "team@zeit.co"
}, },
"repository": "zeit/hyperterm", "repository": "zeit/hyper",
"description": "HTML/JS/CSS Terminal", "description": "HTML/JS/CSS Terminal",
"dependencies": { "dependencies": {
"child_pty": "3.0.1", "child_pty": "3.0.1",

View file

@ -16,8 +16,8 @@ const notify = require('./notify');
const cache = new Config(); const cache = new Config();
// modules path // modules path
const path = resolve(homedir(), '.hyperterm_plugins'); const path = resolve(homedir(), '.hyper_plugins');
const localPath = resolve(homedir(), '.hyperterm_plugins', 'local'); const localPath = resolve(homedir(), '.hyper_plugins', 'local');
const availableExtensions = new Set([ const availableExtensions = new Set([
'onApp', 'onWindow', 'onUnload', 'middleware', 'onApp', 'onWindow', 'onUnload', 'middleware',
'reduceUI', 'reduceSessions', 'decorateMenu', 'reduceUI', 'reduceSessions', 'decorateMenu',
@ -78,12 +78,12 @@ function updatePlugins({force = false} = {}) {
} else { } else {
notify( notify(
'Error updating plugins.', 'Error updating plugins.',
'Check `~/.hyperterm_plugins/npm-debug.log` for more information.' 'Check `~/.hyper_plugins/npm-debug.log` for more information.'
); );
} }
} else { } else {
// flag successful plugin update // flag successful plugin update
cache.set('hyperterm.plugins', id_); cache.set('hyper.plugins', id_);
// cache paths // cache paths
paths = getPaths(plugins); paths = getPaths(plugins);
@ -97,8 +97,8 @@ function updatePlugins({force = false} = {}) {
const loaded = modules.length; const loaded = modules.length;
const total = paths.plugins.length + paths.localPlugins.length; const total = paths.plugins.length + paths.localPlugins.length;
const pluginVersions = JSON.stringify(getPluginVersions()); const pluginVersions = JSON.stringify(getPluginVersions());
const changed = cache.get('hyperterm.plugin-versions') !== pluginVersions && loaded === total; const changed = cache.get('hyper.plugin-versions') !== pluginVersions && loaded === total;
cache.set('hyperterm.plugin-versions', pluginVersions); cache.set('hyper.plugin-versions', pluginVersions);
// notify watchers // notify watchers
if (force || changed) { if (force || changed) {
@ -154,7 +154,7 @@ exports.updatePlugins = updatePlugins;
// we schedule the initial plugins update // we schedule the initial plugins update
// a bit after the user launches the terminal // a bit after the user launches the terminal
// to prevent slowness // 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 // install immediately if the user changed plugins
console.log('plugins have changed / not init, scheduling plugins installation'); console.log('plugins have changed / not init, scheduling plugins installation');
setTimeout(() => { setTimeout(() => {
@ -168,13 +168,13 @@ setInterval(updatePlugins, ms('5h'));
function syncPackageJSON() { function syncPackageJSON() {
const dependencies = toDependencies(plugins); const dependencies = toDependencies(plugins);
const pkg = { const pkg = {
name: 'hyperterm-plugins', name: 'hyper-plugins',
description: 'Auto-generated from `~/.hyperterm.js`!', description: 'Auto-generated from `~/.hyper.js`!',
private: true, private: true,
version: '0.0.1', version: '0.0.1',
repository: 'zeit/hyperterm', repository: 'zeit/hyper',
license: 'MIT', license: 'MIT',
homepage: 'https://hyperterm.org', homepage: 'https://hyper.is',
dependencies dependencies
}; };
@ -276,7 +276,7 @@ function requirePlugins() {
const exposed = mod && Object.keys(mod).some(key => availableExtensions.has(key)); const exposed = mod && Object.keys(mod).some(key => availableExtensions.has(key));
if (!exposed) { if (!exposed) {
notify('Plugin error!', `Plugin "${basename(path)}" does not expose any ` + notify('Plugin error!', `Plugin "${basename(path)}" does not expose any ` +
'HyperTerm extension API methods'); 'Hyper extension API methods');
return; return;
} }

View file

@ -17,7 +17,7 @@ try {
'A native module failed to load. Typically this means ' + 'A native module failed to load. Typically this means ' +
'you installed the modules incorrectly.\n Use `scripts/install.sh` ' + 'you installed the modules incorrectly.\n Use `scripts/install.sh` ' +
'to trigger the installation.\n ' + 'to trigger the installation.\n ' +
'More information: https://github.com/zeit/hyperterm/issues/72' 'More information: https://github.com/zeit/hyper/issues/72'
); );
} }

View file

@ -213,9 +213,9 @@ export function showPreferences() {
dispatch(sendSessionData( dispatch(sendSessionData(
uid, uid,
// Leading space prevents command to be store in shell history // 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!', ' 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') ].join('\n')
)); ));

View file

@ -82,7 +82,7 @@ export default class Notifications extends Component {
window.require('electron').shell.openExternal(ev.target.href); window.require('electron').shell.openExternal(ev.target.href);
ev.preventDefault(); 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</a>). >notes</a>).
{' '} {' '}
<a <a

View file

@ -1,8 +1,8 @@
{ {
"name": "hyperterm", "name": "hyper",
"version": "0.8.0", "version": "0.8.0",
"description": "Web app that runs in the renderer process", "description": "Web app that runs in the renderer process",
"repository": "zeit/hyperterm", "repository": "zeit/hyper",
"license": "MIT", "license": "MIT",
"author": { "author": {
"name": "Zeit, Inc.", "name": "Zeit, Inc.",
@ -89,7 +89,7 @@
] ]
}, },
"build": { "build": {
"appId": "co.zeit.hyperterm", "appId": "co.zeit.hyper",
"asar": false, "asar": false,
"extend-info": "build/Info.plist", "extend-info": "build/Info.plist",
"linux": { "linux": {