mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-16 13:48:41 -09:00
parent
5300b77813
commit
300f7cbde4
5 changed files with 84 additions and 72 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
const {writeFileSync, readFileSync} = require('fs');
|
const {writeFileSync, readFileSync} = require('fs');
|
||||||
const {defaultCfg, cfgPath} = require('./paths');
|
const {sync: mkdirpSync} = require('mkdirp');
|
||||||
|
const {defaultCfg, cfgPath, plugs} = require('./paths');
|
||||||
const _init = require('./init');
|
const _init = require('./init');
|
||||||
const _keymaps = require('./keymaps');
|
const _keymaps = require('./keymaps');
|
||||||
|
|
||||||
|
|
@ -15,6 +16,10 @@ const _write = function (path, data) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const _importConf = function () {
|
const _importConf = function () {
|
||||||
|
// init plugin directories if not present
|
||||||
|
mkdirpSync(plugs.base);
|
||||||
|
mkdirpSync(plugs.local);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const _defaultCfg = readFileSync(defaultCfg, 'utf8');
|
const _defaultCfg = readFileSync(defaultCfg, 'utf8');
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,14 @@ const devDir = resolve(__dirname, '../..');
|
||||||
const devCfg = join(devDir, cfgFile);
|
const devCfg = join(devDir, cfgFile);
|
||||||
const defaultCfg = resolve(__dirname, defaultCfgFile);
|
const defaultCfg = resolve(__dirname, defaultCfgFile);
|
||||||
|
|
||||||
|
const plugins = resolve(cfgDir, '.hyper_plugins');
|
||||||
|
const plugs = {
|
||||||
|
base: plugins,
|
||||||
|
local: resolve(plugins, 'local'),
|
||||||
|
cache: resolve(plugins, 'cache')
|
||||||
|
};
|
||||||
|
const yarn = resolve(__dirname, '../../bin/yarn-standalone.js');
|
||||||
|
|
||||||
const icon = resolve(__dirname, '../static/icon.png');
|
const icon = resolve(__dirname, '../static/icon.png');
|
||||||
|
|
||||||
const keymapPath = resolve(__dirname, '../keymaps');
|
const keymapPath = resolve(__dirname, '../keymaps');
|
||||||
|
|
@ -44,5 +52,5 @@ if (isDev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
cfgDir, cfgPath, cfgFile, defaultCfg, icon, defaultPlatformKeyPath
|
cfgDir, cfgPath, cfgFile, defaultCfg, icon, defaultPlatformKeyPath, plugs, yarn
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,21 @@
|
||||||
const {app, dialog} = require('electron');
|
const {app, dialog} = require('electron');
|
||||||
const {resolve, basename} = require('path');
|
const {resolve, basename} = require('path');
|
||||||
const {writeFileSync} = require('fs');
|
const {writeFileSync} = require('fs');
|
||||||
const cp = require('child_process');
|
|
||||||
const {sync: mkdirpSync} = require('mkdirp');
|
|
||||||
const Config = require('electron-config');
|
const Config = require('electron-config');
|
||||||
const ms = require('ms');
|
const ms = require('ms');
|
||||||
const queue = require('queue');
|
|
||||||
|
|
||||||
const spawnQueue = queue({concurrency: 1});
|
|
||||||
|
|
||||||
const config = require('./config');
|
const config = require('./config');
|
||||||
const notify = require('./notify');
|
const notify = require('./notify');
|
||||||
const _keys = require('./config/keymaps');
|
const _keys = require('./config/keymaps');
|
||||||
|
const {availableExtensions} = require('./plugins/extensions');
|
||||||
|
const {install} = require('./plugins/install');
|
||||||
|
const {plugs} = require('./config/paths');
|
||||||
|
|
||||||
// local storage
|
// local storage
|
||||||
const cache = new Config();
|
const cache = new Config();
|
||||||
|
|
||||||
// modules path
|
const path = plugs.base;
|
||||||
const path = resolve(config.getConfigDir(), '.hyper_plugins');
|
const localPath = plugs.local;
|
||||||
const localPath = resolve(path, 'local');
|
|
||||||
const cachePath = resolve(path, 'cache');
|
|
||||||
const availableExtensions = new Set([
|
|
||||||
'onApp', 'onWindow', 'onRendererWindow', 'onUnload', 'middleware',
|
|
||||||
'reduceUI', 'reduceSessions', 'reduceTermGroups',
|
|
||||||
'decorateMenu', 'decorateTerm', 'decorateHyper',
|
|
||||||
'decorateHyperTerm', // for backwards compatibility with hyperterm
|
|
||||||
'decorateHeader', 'decorateTerms', 'decorateTab',
|
|
||||||
'decorateNotification', 'decorateNotifications',
|
|
||||||
'decorateTabs', 'decorateConfig', 'decorateEnv',
|
|
||||||
'decorateTermGroup', 'decorateSplitPane', 'getTermProps',
|
|
||||||
'getTabProps', 'getTabsProps', 'getTermGroupProps',
|
|
||||||
'mapHyperTermState', 'mapTermsState',
|
|
||||||
'mapHeaderState', 'mapNotificationsState',
|
|
||||||
'mapHyperTermDispatch', 'mapTermsDispatch',
|
|
||||||
'mapHeaderDispatch', 'mapNotificationsDispatch',
|
|
||||||
'extendKeymaps'
|
|
||||||
]);
|
|
||||||
|
|
||||||
// init plugin directories if not present
|
|
||||||
mkdirpSync(path);
|
|
||||||
mkdirpSync(localPath);
|
|
||||||
|
|
||||||
// caches
|
// caches
|
||||||
let plugins = config.getPlugins();
|
let plugins = config.getPlugins();
|
||||||
|
|
@ -222,47 +198,6 @@ function toDependencies(plugins) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
function install(fn) {
|
|
||||||
function yarn(args, cb) {
|
|
||||||
const yarnPath = resolve(__dirname, '..', 'bin', 'yarn-standalone.js');
|
|
||||||
const env = {
|
|
||||||
NODE_ENV: 'production',
|
|
||||||
ELECTRON_RUN_AS_NODE: 'true'
|
|
||||||
};
|
|
||||||
|
|
||||||
spawnQueue.push(end => {
|
|
||||||
const cmd = [process.execPath, yarnPath].concat(args).join(' ');
|
|
||||||
console.log('Launching yarn:', cmd);
|
|
||||||
|
|
||||||
cp.exec(cmd, {
|
|
||||||
cwd: path,
|
|
||||||
env,
|
|
||||||
shell: true,
|
|
||||||
timeout: ms('5m'),
|
|
||||||
stdio: ['ignore', 'ignore', 'inherit']
|
|
||||||
}, err => {
|
|
||||||
if (err) {
|
|
||||||
cb(err);
|
|
||||||
} else {
|
|
||||||
cb(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
end();
|
|
||||||
spawnQueue.start();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
spawnQueue.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
yarn(['install', '--no-emoji', '--no-lockfile', '--cache-folder', cachePath], err => {
|
|
||||||
if (err) {
|
|
||||||
return fn(err);
|
|
||||||
}
|
|
||||||
fn(null);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.subscribe = function (fn) {
|
exports.subscribe = function (fn) {
|
||||||
watchers.push(fn);
|
watchers.push(fn);
|
||||||
return () => {
|
return () => {
|
||||||
|
|
|
||||||
18
app/plugins/extensions.js
Normal file
18
app/plugins/extensions.js
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
module.exports = {
|
||||||
|
availableExtensions: new Set([
|
||||||
|
'onApp', 'onWindow', 'onRendererWindow', 'onUnload', 'middleware',
|
||||||
|
'reduceUI', 'reduceSessions', 'reduceTermGroups',
|
||||||
|
'decorateMenu', 'decorateTerm', 'decorateHyper',
|
||||||
|
'decorateHyperTerm', // for backwards compatibility with hyperterm
|
||||||
|
'decorateHeader', 'decorateTerms', 'decorateTab',
|
||||||
|
'decorateNotification', 'decorateNotifications',
|
||||||
|
'decorateTabs', 'decorateConfig', 'decorateEnv',
|
||||||
|
'decorateTermGroup', 'decorateSplitPane', 'getTermProps',
|
||||||
|
'getTabProps', 'getTabsProps', 'getTermGroupProps',
|
||||||
|
'mapHyperTermState', 'mapTermsState',
|
||||||
|
'mapHeaderState', 'mapNotificationsState',
|
||||||
|
'mapHyperTermDispatch', 'mapTermsDispatch',
|
||||||
|
'mapHeaderDispatch', 'mapNotificationsDispatch',
|
||||||
|
'extendKeymaps'
|
||||||
|
])
|
||||||
|
};
|
||||||
46
app/plugins/install.js
Normal file
46
app/plugins/install.js
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
const cp = require('child_process');
|
||||||
|
const queue = require('queue');
|
||||||
|
const ms = require('ms');
|
||||||
|
const {yarn, plugs} = require('../config/paths');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
install: fn => {
|
||||||
|
const spawnQueue = queue({concurrency: 1});
|
||||||
|
function yarnFn(args, cb) {
|
||||||
|
const env = {
|
||||||
|
NODE_ENV: 'production',
|
||||||
|
ELECTRON_RUN_AS_NODE: 'true'
|
||||||
|
};
|
||||||
|
spawnQueue.push(end => {
|
||||||
|
const cmd = [process.execPath, yarn].concat(args).join(' ');
|
||||||
|
console.log('Launching yarn:', cmd);
|
||||||
|
|
||||||
|
cp.exec(cmd, {
|
||||||
|
cwd: plugs.base,
|
||||||
|
env,
|
||||||
|
shell: true,
|
||||||
|
timeout: ms('5m'),
|
||||||
|
stdio: ['ignore', 'ignore', 'inherit']
|
||||||
|
}, err => {
|
||||||
|
if (err) {
|
||||||
|
cb(err);
|
||||||
|
} else {
|
||||||
|
cb(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
end();
|
||||||
|
spawnQueue.start();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
spawnQueue.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
yarnFn(['install', '--no-emoji', '--no-lockfile', '--cache-folder', plugs.cache], err => {
|
||||||
|
if (err) {
|
||||||
|
return fn(err);
|
||||||
|
}
|
||||||
|
fn(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue