This commit is contained in:
Eugene Pankov 2017-04-15 15:20:18 +02:00
parent f17df2bde5
commit c19f0b1895
28 changed files with 88 additions and 75 deletions

View file

@ -6,7 +6,7 @@ SHORT_VERSION=$(shell python -c 'import subprocess; v = subprocess.check_output(
all: run all: run
run: run:
DEV=1 NODE_PATH=./app/node_modules ./node_modules/.bin/electron ./app --debug DEV=1 TERMINUS_PLUGINS=`realpath .` ./node_modules/.bin/electron ./app --debug
lint: lint:
tslint -c tslint.json app/src/*.ts app/src/**/*.ts tslint -c tslint.json app/src/*.ts app/src/**/*.ts

View file

@ -131,7 +131,7 @@ start = () => {
width: 800, width: 800,
height: 400, height: 400,
//icon: `${app.getAppPath()}/assets/img/icon.png`, //icon: `${app.getAppPath()}/assets/img/icon.png`,
title: 'Term', title: 'Terminus',
minWidth: 300, minWidth: 300,
minHeight: 100, minHeight: 100,
'web-preferences': {'web-security': false}, 'web-preferences': {'web-security': false},

View file

@ -2,6 +2,10 @@
"name": "terminus", "name": "terminus",
"version": "0.0.1", "version": "0.0.1",
"main": "main.js", "main": "main.js",
"scripts": {
"build": "../node_modules/.bin/webpack --progress --color --display-modules",
"watch": "../node_modules/.bin/webpack --progress --color --watch"
},
"dependencies": { "dependencies": {
"@angular/animations": "4.0.1", "@angular/animations": "4.0.1",
"@angular/common": "4.0.1", "@angular/common": "4.0.1",
@ -15,6 +19,7 @@
"electron-config": "0.2.1", "electron-config": "0.2.1",
"electron-debug": "1.0.1", "electron-debug": "1.0.1",
"electron-is-dev": "0.1.2", "electron-is-dev": "0.1.2",
"fs-promise": "^2.0.2",
"js-yaml": "3.8.2", "js-yaml": "3.8.2",
"path": "0.12.7", "path": "0.12.7",
"rxjs": "5.3.0", "rxjs": "5.3.0",

View file

@ -1,28 +1,23 @@
import { NgModule } from '@angular/core' import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { NgbModule } from '@ng-bootstrap/ng-bootstrap' import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
import { loadPlugins } from './plugins'
const projectRoot = '/home/eugene/Work/term/' export async function getRootModule(): Promise<any> {
if (process.env.DEV) { let plugins = await loadPlugins()
(<any>global).require('module').globalPaths.push(projectRoot); let imports = [
(<any>global).require('module').globalPaths.push(projectRoot + 'app/node_modules') BrowserModule,
} ...(plugins.map(x => x.default.forRoot ? x.default.forRoot() : x.default)),
NgbModule.forRoot(),
let plugins = [ ]
(<any>global).require(projectRoot + 'terminus-settings').default, let bootstrap = [
(<any>global).require(projectRoot + 'terminus-terminal').default, ...(plugins.filter(x => x.bootstrap).map(x => x.bootstrap)),
(<any>global).require(projectRoot + 'terminus-clickable-links').default,
(<any>global).require(projectRoot + 'terminus-community-color-schemes').default,
(<any>global).require(projectRoot + 'terminus-theme-hype').default,
] ]
const core = (<any>global).require(projectRoot + 'terminus-core')
@NgModule({ @NgModule({
imports: [ imports,
core.AppRootModule.forRoot(), bootstrap,
...plugins, }) class RootModule { }
NgbModule.forRoot(),
], return RootModule
bootstrap: [core.AppRootComponent] }
})
export class RootModule { }

View file

@ -3,12 +3,11 @@
import 'core-js' import 'core-js'
import 'zone.js/dist/zone.js' import 'zone.js/dist/zone.js'
import 'core-js/es7/reflect' import 'core-js/es7/reflect'
import 'jquery'
// Always land on the start view // Always land on the start view
location.hash = '' location.hash = ''
import { RootModule } from './app.module' import { getRootModule } from './app.module'
import { enableProdMode } from '@angular/core' import { enableProdMode } from '@angular/core'
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
@ -18,8 +17,6 @@ if ((<any>global).require('electron-is-dev')) {
enableProdMode() enableProdMode()
} }
(<any>console).timeStamp('angular bootstrap started') getRootModule().then(module => {
platformBrowserDynamic().bootstrapModule(RootModule); platformBrowserDynamic().bootstrapModule(module)
})
(<any>process).emitWarning = function () { console.log(arguments) }

32
app/src/plugins.ts Normal file
View file

@ -0,0 +1,32 @@
import * as fs from 'fs-promise'
import * as path from 'path'
let nodeRequire = (<any>global).require
let module = nodeRequire('module')
nodeRequire.main.paths.map(x => module.globalPaths.push(x))
if (process.env.TERMINUS_PLUGINS) {
process.env.TERMINUS_PLUGINS.split(':').map(x => module.globalPaths.push(x))
}
export async function loadPlugins (): Promise<any[]> {
let paths = module.globalPaths
let plugins: any[] = []
for (let pluginDir of paths) {
if (!await fs.exists(pluginDir)) {
continue
}
for (let pluginName of await fs.readdir(pluginDir)) {
if (/^terminus-/.exec(pluginName)) {
let pluginPath = path.join(pluginDir, pluginName)
console.info(`Loading ${pluginName}: ${nodeRequire.resolve(pluginPath)}`)
try {
let pluginModule = nodeRequire(pluginPath)
plugins.push(pluginModule)
} catch (error) {
console.error(`Could not load ${pluginName}:`, error)
}
}
}
}
return plugins
}

View file

@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"baseUrl": "./app/src", "baseUrl": "./src",
"module": "commonjs", "module": "commonjs",
"target": "es5", "target": "es5",
"declaration": false, "declaration": false,

View file

@ -25,8 +25,10 @@ module.exports = {
loaders: [ loaders: [
{ {
test: /\.ts$/, test: /\.ts$/,
use: 'awesome-typescript-loader', loader: 'awesome-typescript-loader',
exclude: [/node_modules/] options: {
configFileName: path.resolve(__dirname, 'tsconfig.json'),
}
}, },
{ {
test: /\.scss$/, test: /\.scss$/,
@ -40,14 +42,14 @@ module.exports = {
test: /\.(png|svg)$/, test: /\.(png|svg)$/,
loader: "file-loader", loader: "file-loader",
options: { options: {
name: 'images/[name].[hash:8].[ext]' name: 'images/[name].[ext]'
} }
}, },
{ {
test: /\.(ttf|eot|otf|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/, test: /\.(ttf|eot|otf|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "file-loader", loader: "file-loader",
options: { options: {
name: 'fonts/[name].[hash:8].[ext]' name: 'fonts/[name].[ext]'
} }
} }
] ]
@ -60,6 +62,9 @@ module.exports = {
'@angular/forms': 'commonjs @angular/forms', '@angular/forms': 'commonjs @angular/forms',
'@angular/common': 'commonjs @angular/common', '@angular/common': 'commonjs @angular/common',
'@ng-bootstrap/ng-bootstrap': 'commonjs @ng-bootstrap/ng-bootstrap', '@ng-bootstrap/ng-bootstrap': 'commonjs @ng-bootstrap/ng-bootstrap',
'fs-promise': 'commonjs fs-promise',
'module': 'commonjs module',
'path': 'commonjs path',
'rxjs': 'commonjs rxjs', 'rxjs': 'commonjs rxjs',
'zone.js': 'commonjs zone.js', 'zone.js': 'commonjs zone.js',
}, },

View file

@ -2,7 +2,6 @@
"name": "term", "name": "term",
"devDependencies": { "devDependencies": {
"angular2-perfect-scrollbar": "2.0.0", "angular2-perfect-scrollbar": "2.0.0",
"jquery": "^3.1.1",
"@types/fs-promise": "^1.0.1", "@types/fs-promise": "^1.0.1",
"@types/core-js": "^0.9.35", "@types/core-js": "^0.9.35",
"@types/electron": "1.4.34", "@types/electron": "1.4.34",
@ -36,7 +35,7 @@
"url-loader": "^0.5.7", "url-loader": "^0.5.7",
"val-loader": "^0.5.0", "val-loader": "^0.5.0",
"vrsource-tslint-rules": "^4.0.1", "vrsource-tslint-rules": "^4.0.1",
"webpack": "2.3.3" "webpack": "2.4.1"
}, },
"build": { "build": {
"appId": "com.elements.benchmark", "appId": "com.elements.benchmark",
@ -58,8 +57,8 @@
} }
}, },
"scripts": { "scripts": {
"build": "webpack --progress --color", "build": "node --max-old-space-size=4096 ./node_modules/.bin/webpack --progress --color",
"watch": "webpack --progress --color --watch", "watch": "node --max-old-space-size=4096 ./node_modules/.bin/webpack --progress --color --watch",
"pack": "build --dir", "pack": "build --dir",
"postinstall": "install-app-deps", "postinstall": "install-app-deps",
"dist": "build" "dist": "build"

View file

@ -20,11 +20,7 @@
"dom", "dom",
"es2015", "es2015",
"es7" "es7"
], ]
"paths": {
"*": ["../../app/node_modules/*"],
"terminus-*": ["../../terminus-*"]
}
}, },
"compileOnSave": false, "compileOnSave": false,
"exclude": [ "exclude": [

View file

@ -22,6 +22,7 @@ module.exports = {
test: /\.ts$/, test: /\.ts$/,
loader: 'awesome-typescript-loader', loader: 'awesome-typescript-loader',
query: { query: {
configFileName: path.resolve(__dirname, 'tsconfig.json'),
paths: { paths: {
"terminus-*": [path.resolve(__dirname, '../terminus-*')], "terminus-*": [path.resolve(__dirname, '../terminus-*')],
"*": [path.resolve(__dirname, '../app/node_modules/*')], "*": [path.resolve(__dirname, '../app/node_modules/*')],

View file

@ -20,11 +20,7 @@
"dom", "dom",
"es2015", "es2015",
"es7" "es7"
], ]
"paths": {
"*": ["../../app/node_modules/*"],
"terminus-*": ["../../terminus-*"]
}
}, },
"compileOnSave": false, "compileOnSave": false,
"exclude": [ "exclude": [

View file

@ -22,6 +22,7 @@ module.exports = {
test: /\.ts$/, test: /\.ts$/,
loader: 'awesome-typescript-loader', loader: 'awesome-typescript-loader',
options: { options: {
configFileName: path.resolve(__dirname, 'tsconfig.json'),
paths: { paths: {
"terminus-*": [path.resolve(__dirname, '../terminus-*')], "terminus-*": [path.resolve(__dirname, '../terminus-*')],
"*": [path.resolve(__dirname, '../app/node_modules/*')], "*": [path.resolve(__dirname, '../app/node_modules/*')],

View file

@ -1 +0,0 @@
export * from 'rxjs'

View file

@ -55,8 +55,6 @@ export class AppRootComponent {
_themes: ThemesService, _themes: ThemesService,
_quitter: QuitterService, _quitter: QuitterService,
) { ) {
(<any>console).timeStamp('AppComponent ctor')
this.logger = log.create('main') this.logger = log.create('main')
this.logger.info('v', electron.app.getVersion()) this.logger.info('v', electron.app.getVersion())

View file

@ -1,4 +1,4 @@
.title((dblclick)='hostApp.toggleMaximize()') Term .title((dblclick)='hostApp.toggleMaximize()') Terminus
button.btn.btn-secondary.btn-minimize((click)='hostApp.minimize()') button.btn.btn-secondary.btn-minimize((click)='hostApp.minimize()')
i.fa.fa-window-minimize i.fa.fa-window-minimize
button.btn.btn-secondary.btn-maximize((click)='hostApp.toggleMaximize()') button.btn.btn-secondary.btn-maximize((click)='hostApp.toggleMaximize()')

View file

@ -1,5 +1,4 @@
import { NgModule, ModuleWithProviders } from '@angular/core' import { NgModule, ModuleWithProviders } from '@angular/core'
console.info((<any>global).require.resolve('@angular/core'))
import { BrowserModule } from '@angular/platform-browser' import { BrowserModule } from '@angular/platform-browser'
import { BrowserAnimationsModule } from '@angular/platform-browser/animations' import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
import { FormsModule } from '@angular/forms' import { FormsModule } from '@angular/forms'
@ -64,9 +63,6 @@ const PROVIDERS = [
], ],
}) })
export default class AppModule { export default class AppModule {
}
export class AppRootModule {
static forRoot(): ModuleWithProviders { static forRoot(): ModuleWithProviders {
return { return {
ngModule: AppModule, ngModule: AppModule,
@ -75,5 +71,5 @@ export class AppRootModule {
} }
} }
export { AppRootComponent } export { AppRootComponent as bootstrap }
export * from './api' export * from './api'

View file

@ -53,7 +53,7 @@ const configMerge = (a, b) => require('deepmerge')(a, b, { arrayMerge: (_d, s) =
@Injectable() @Injectable()
export class ConfigService { export class ConfigService {
store: ConfigProxy store: any
change = new EventEmitter() change = new EventEmitter()
restartRequested: boolean restartRequested: boolean
private _store: any private _store: any

View file

@ -1,6 +1,5 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
@Injectable() @Injectable()
export class ElectronService { export class ElectronService {
constructor() { constructor() {

View file

@ -28,7 +28,7 @@ export class HostAppService {
electron.ipcRenderer.on('host:quit-request', () => this.zone.run(() => this.quitRequested.emit())) electron.ipcRenderer.on('host:quit-request', () => this.zone.run(() => this.quitRequested.emit()))
electron.ipcRenderer.on('uncaughtException', function(err) { electron.ipcRenderer.on('uncaughtException', function(err) {
console.error('Unhandled exception:', err) this.logger.error('Unhandled exception:', err)
}) })
electron.ipcRenderer.on('host:window-shown', () => { electron.ipcRenderer.on('host:window-shown', () => {

View file

@ -22,6 +22,7 @@ module.exports = {
test: /\.ts$/, test: /\.ts$/,
loader: 'awesome-typescript-loader', loader: 'awesome-typescript-loader',
options: { options: {
configFileName: path.resolve(__dirname, 'tsconfig.json'),
paths: { paths: {
"terminus-*": [path.resolve(__dirname, '../terminus-*')], "terminus-*": [path.resolve(__dirname, '../terminus-*')],
"*": [path.resolve(__dirname, '../app/node_modules/*')], "*": [path.resolve(__dirname, '../app/node_modules/*')],

View file

@ -1 +0,0 @@
export * from 'zone.js'

View file

@ -22,6 +22,7 @@ module.exports = {
test: /\.ts$/, test: /\.ts$/,
loader: 'awesome-typescript-loader', loader: 'awesome-typescript-loader',
options: { options: {
configFileName: path.resolve(__dirname, 'tsconfig.json'),
paths: { paths: {
"terminus-*": [path.resolve(__dirname, '../terminus-*')], "terminus-*": [path.resolve(__dirname, '../terminus-*')],
"*": [path.resolve(__dirname, '../app/node_modules/*')], "*": [path.resolve(__dirname, '../app/node_modules/*')],

View file

@ -23,7 +23,6 @@ export class Session {
constructor (options: SessionOptions) { constructor (options: SessionOptions) {
this.name = options.name this.name = options.name
this.recoveryId = options.recoveryId this.recoveryId = options.recoveryId
console.log('Spawning', options.command)
let env = { let env = {
...process.env, ...process.env,

View file

@ -22,6 +22,7 @@ module.exports = {
test: /\.ts$/, test: /\.ts$/,
loader: 'awesome-typescript-loader', loader: 'awesome-typescript-loader',
query: { query: {
configFileName: path.resolve(__dirname, 'tsconfig.json'),
paths: { paths: {
"terminus-*": [path.resolve(__dirname, '../terminus-*')], "terminus-*": [path.resolve(__dirname, '../terminus-*')],
"*": [path.resolve(__dirname, '../app/node_modules/*')], "*": [path.resolve(__dirname, '../app/node_modules/*')],

View file

@ -12,11 +12,7 @@
"dom", "dom",
"es2015", "es2015",
"es7" "es7"
], ]
"paths": {
"*": ["../../app/node_modules/*"],
"terminus-*": ["../../terminus-*"]
}
}, },
"exclude": [ "exclude": [
"node_modules" "node_modules"

View file

@ -21,6 +21,7 @@ module.exports = {
test: /\.ts$/, test: /\.ts$/,
loader: 'awesome-typescript-loader', loader: 'awesome-typescript-loader',
options: { options: {
configFileName: path.resolve(__dirname, 'tsconfig.json'),
paths: { paths: {
"terminus-*": [path.resolve(__dirname, '../terminus-*')], "terminus-*": [path.resolve(__dirname, '../terminus-*')],
"*": [path.resolve(__dirname, '../app/node_modules/*')], "*": [path.resolve(__dirname, '../app/node_modules/*')],

View file

@ -4,10 +4,6 @@
"node_modules/tslint-eslint-rules/dist/rules" "node_modules/tslint-eslint-rules/dist/rules"
], ],
"rules": { "rules": {
"no-console": [
true,
"log"
],
"no-duplicate-imports": true, "no-duplicate-imports": true,
"no-duplicate-variable": true, "no-duplicate-variable": true,
"no-jasmine-focus": true, "no-jasmine-focus": true,