mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-08 21:40:03 +00:00
.
This commit is contained in:
parent
64556806e6
commit
2d1dca41d7
@ -27,7 +27,9 @@ if (!process.env.TERMINUS_PLUGINS) {
|
|||||||
process.env.TERMINUS_PLUGINS = ''
|
process.env.TERMINUS_PLUGINS = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
process.env.TERMINUS_PLUGINS += `:${path.resolve(__dirname, '..')}`
|
if (process.env.DEV) {
|
||||||
|
process.env.TERMINUS_PLUGINS += `:${path.resolve(__dirname, '..')}`
|
||||||
|
}
|
||||||
|
|
||||||
setupWindowManagement = () => {
|
setupWindowManagement = () => {
|
||||||
let windowCloseable
|
let windowCloseable
|
||||||
|
@ -12,7 +12,7 @@ import { enableProdMode } from '@angular/core'
|
|||||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
|
||||||
|
|
||||||
import { getRootModule } from './app.module'
|
import { getRootModule } from './app.module'
|
||||||
import { loadPlugins } from './plugins'
|
import { findPlugins, loadPlugins } from './plugins'
|
||||||
|
|
||||||
if ((<any>global).require('electron-is-dev')) {
|
if ((<any>global).require('electron-is-dev')) {
|
||||||
console.warn('Running in debug mode')
|
console.warn('Running in debug mode')
|
||||||
@ -20,9 +20,10 @@ if ((<any>global).require('electron-is-dev')) {
|
|||||||
enableProdMode()
|
enableProdMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPlugins((current, total) => {
|
findPlugins().then(async plugins => {
|
||||||
(<HTMLElement>document.querySelector('.progress .bar')).style.width = 100 * current / total + '%'
|
let pluginsModules = loadPlugins(plugins, (current, total) => {
|
||||||
}).then(async plugins => {
|
(<HTMLElement>document.querySelector('.progress .bar')).style.width = 100 * current / total + '%'
|
||||||
let module = await getRootModule(plugins)
|
})
|
||||||
|
let module = await getRootModule(pluginsModules)
|
||||||
platformBrowserDynamic().bootstrapModule(module)
|
platformBrowserDynamic().bootstrapModule(module)
|
||||||
})
|
})
|
||||||
|
@ -19,27 +19,46 @@ if (process.env.TERMINUS_PLUGINS) {
|
|||||||
|
|
||||||
export declare type ProgressCallback = (current, total) => void
|
export declare type ProgressCallback = (current, total) => void
|
||||||
|
|
||||||
interface IFoundPlugin {
|
interface IPluginEntry {
|
||||||
name: string
|
name: string
|
||||||
path: string
|
path: string
|
||||||
|
info: any
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadPlugins (progress: ProgressCallback): Promise<any[]> {
|
export async function findPlugins (): Promise<IPluginEntry[]> {
|
||||||
let paths = nodeModule.globalPaths
|
let paths = nodeModule.globalPaths
|
||||||
let plugins: any[] = []
|
let foundPlugins: IPluginEntry[] = []
|
||||||
let foundPlugins: IFoundPlugin[] = []
|
|
||||||
|
|
||||||
progress(0, 1)
|
|
||||||
for (let pluginDir of paths) {
|
for (let pluginDir of paths) {
|
||||||
pluginDir = normalizePath(pluginDir)
|
pluginDir = normalizePath(pluginDir)
|
||||||
if (!await fs.exists(pluginDir)) {
|
if (!await fs.exists(pluginDir)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
let pluginNames = await fs.readdir(pluginDir)
|
let pluginNames = await fs.readdir(pluginDir)
|
||||||
pluginNames.filter(pluginName => /^terminus-/.exec(pluginName)).forEach(name => {
|
for (let pluginName of pluginNames.filter(x => /^terminus-/.exec(x))) {
|
||||||
foundPlugins.push({ name, path: path.join(pluginDir, name) })
|
let pluginPath = path.join(pluginDir, pluginName)
|
||||||
})
|
let infoPath = path.join(pluginPath, 'package.json')
|
||||||
|
if (!await fs.exists(infoPath)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
foundPlugins.push({
|
||||||
|
name: pluginName,
|
||||||
|
path: pluginPath,
|
||||||
|
info: await fs.readJson(infoPath),
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Cannot load package info for', pluginName)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return foundPlugins
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadPlugins (foundPlugins: IPluginEntry[], progress: ProgressCallback): any[] {
|
||||||
|
let plugins: any[] = []
|
||||||
|
progress(0, 1)
|
||||||
foundPlugins.forEach((foundPlugin, index) => {
|
foundPlugins.forEach((foundPlugin, index) => {
|
||||||
console.info(`Loading ${foundPlugin.name}: ${(<any>global).require.resolve(foundPlugin.path)}`)
|
console.info(`Loading ${foundPlugin.name}: ${(<any>global).require.resolve(foundPlugin.path)}`)
|
||||||
progress(index, foundPlugins.length)
|
progress(index, foundPlugins.length)
|
||||||
@ -50,7 +69,6 @@ export async function loadPlugins (progress: ProgressCallback): Promise<any[]> {
|
|||||||
console.error(`Could not load ${foundPlugin.name}:`, error)
|
console.error(`Could not load ${foundPlugin.name}:`, error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
progress(1, 1)
|
progress(1, 1)
|
||||||
return plugins
|
return plugins
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ module.exports = {
|
|||||||
'fs-promise',
|
'fs-promise',
|
||||||
'path',
|
'path',
|
||||||
'node-pty',
|
'node-pty',
|
||||||
'child-process-promise',
|
|
||||||
'fs-promise',
|
'fs-promise',
|
||||||
/^rxjs/,
|
/^rxjs/,
|
||||||
/^@angular/,
|
/^@angular/,
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/deep-equal": "^1.0.0",
|
"@types/deep-equal": "^1.0.0",
|
||||||
|
"@types/mz": "0.0.31",
|
||||||
"@types/node": "7.0.12",
|
"@types/node": "7.0.12",
|
||||||
"@types/webpack-env": "1.13.0",
|
"@types/webpack-env": "1.13.0",
|
||||||
"@types/winreg": "^1.2.30",
|
"@types/winreg": "^1.2.30",
|
||||||
@ -38,10 +39,10 @@
|
|||||||
"rxjs": "5.3.0"
|
"rxjs": "5.3.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"child-process-promise": "2.2.1",
|
|
||||||
"font-manager": "0.2.2",
|
"font-manager": "0.2.2",
|
||||||
"fs-promise": "2.0.2",
|
"fs-promise": "2.0.2",
|
||||||
"hterm-commonjs": "1.0.0",
|
"hterm-commonjs": "1.0.0",
|
||||||
|
"mz": "^2.6.0",
|
||||||
"node-pty": "0.6.2",
|
"node-pty": "0.6.2",
|
||||||
"winreg": "^1.2.3"
|
"winreg": "^1.2.3"
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { Observable } from 'rxjs'
|
import { Observable } from 'rxjs'
|
||||||
import * as fs from 'fs-promise'
|
import * as fs from 'fs-promise'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
|
import { exec } from 'mz/child_process'
|
||||||
const equal = require('deep-equal')
|
const equal = require('deep-equal')
|
||||||
const fontManager = require('font-manager')
|
const fontManager = require('font-manager')
|
||||||
const { exec } = require('child-process-promise')
|
|
||||||
|
|
||||||
import { Component, Inject } from '@angular/core'
|
import { Component, Inject } from '@angular/core'
|
||||||
import { ConfigService, HostAppService, Platform } from 'terminus-core'
|
import { ConfigService, HostAppService, Platform } from 'terminus-core'
|
||||||
@ -44,8 +44,8 @@ export class TerminalSettingsTabComponent {
|
|||||||
this.fonts.sort()
|
this.fonts.sort()
|
||||||
}
|
}
|
||||||
if (this.hostApp.platform == Platform.Linux) {
|
if (this.hostApp.platform == Platform.Linux) {
|
||||||
exec('fc-list :spacing=mono').then((result) => {
|
exec('fc-list :spacing=mono').then(([stdout, _]) => {
|
||||||
this.fonts = result.stdout
|
this.fonts = stdout
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter(x => !!x)
|
.filter(x => !!x)
|
||||||
.map(x => x.split(':')[1].trim())
|
.map(x => x.split(':')[1].trim())
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as fs from 'fs-promise'
|
import * as fs from 'fs-promise'
|
||||||
const { exec, spawn } = require('child-process-promise')
|
import { exec, spawn } from 'mz/child_process'
|
||||||
|
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { Logger, LogService } from 'terminus-core'
|
import { Logger, LogService } from 'terminus-core'
|
||||||
@ -13,7 +13,7 @@ interface IChildProcess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function listProcesses (): Promise<IChildProcess[]> {
|
async function listProcesses (): Promise<IChildProcess[]> {
|
||||||
return (await exec(`ps -A -o pid,ppid,command`)).stdout
|
return (await exec(`ps -A -o pid,ppid,command`))[0].toString()
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.slice(1)
|
.slice(1)
|
||||||
.map(line => line.split(' ').filter(x => x).slice(0, 3))
|
.map(line => line.split(' ').filter(x => x).slice(0, 3))
|
||||||
@ -38,7 +38,7 @@ export class ScreenPersistenceProvider extends SessionPersistenceProvider {
|
|||||||
async attachSession (recoveryId: any): Promise<SessionOptions> {
|
async attachSession (recoveryId: any): Promise<SessionOptions> {
|
||||||
let lines: string[]
|
let lines: string[]
|
||||||
try {
|
try {
|
||||||
lines = (await exec('screen -list')).stdout.split('\n')
|
lines = (await exec('screen -list'))[0].toString().split('\n')
|
||||||
} catch (result) {
|
} catch (result) {
|
||||||
lines = result.stdout.split('\n')
|
lines = result.stdout.split('\n')
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import * as fs from 'fs-promise'
|
|||||||
import { Subject } from 'rxjs'
|
import { Subject } from 'rxjs'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { Logger, LogService } from 'terminus-core'
|
import { Logger, LogService } from 'terminus-core'
|
||||||
const { exec } = require('child-process-promise')
|
import { exec } from 'mz/child_process'
|
||||||
|
|
||||||
import { SessionOptions, SessionPersistenceProvider } from '../api'
|
import { SessionOptions, SessionPersistenceProvider } from '../api'
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ export class Session {
|
|||||||
this.kill()
|
this.kill()
|
||||||
} else {
|
} else {
|
||||||
await new Promise((resolve) => {
|
await new Promise((resolve) => {
|
||||||
this.kill('SIGTERM')
|
this.kill('SIGTERM')
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
if (!this.open) {
|
if (!this.open) {
|
||||||
resolve()
|
resolve()
|
||||||
@ -114,7 +114,7 @@ export class Session {
|
|||||||
|
|
||||||
async getWorkingDirectory (): Promise<string> {
|
async getWorkingDirectory (): Promise<string> {
|
||||||
if (process.platform == 'darwin') {
|
if (process.platform == 'darwin') {
|
||||||
let lines = (await exec(`lsof -p ${this.truePID} -Fn`)).stdout.split('\n')
|
let lines = (await exec(`lsof -p ${this.truePID} -Fn`))[0].toString().split('\n')
|
||||||
return lines[2].substring(1)
|
return lines[2].substring(1)
|
||||||
}
|
}
|
||||||
if (process.platform == 'linux') {
|
if (process.platform == 'linux') {
|
||||||
|
@ -40,7 +40,7 @@ module.exports = {
|
|||||||
'font-manager',
|
'font-manager',
|
||||||
'path',
|
'path',
|
||||||
'node-pty',
|
'node-pty',
|
||||||
'child-process-promise',
|
'mz/child_process',
|
||||||
'winreg',
|
'winreg',
|
||||||
/^rxjs/,
|
/^rxjs/,
|
||||||
/^@angular/,
|
/^@angular/,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user