This commit is contained in:
Eugene Pankov 2017-04-17 14:57:22 +02:00
parent 36c2aef860
commit 919aa7c65f
21 changed files with 108 additions and 78 deletions

View File

@ -22,8 +22,8 @@ install-deps:
npm prune npm prune
for dir in app terminus-* ; do \ for dir in app terminus-* ; do \
cd $$dir; \ cd $$dir; \
npm --color always install 2>&1 | grep -v 'requires a peer'; \ npm install; \
npm --color always prune 2>&1 | grep -v 'requires a peer'; \ npm prune; \
cd ..; \ cd ..; \
done done
make build-native make build-native

View File

@ -14,6 +14,10 @@ export async function getRootModule(): Promise<any> {
...(plugins.filter(x => x.bootstrap).map(x => x.bootstrap)), ...(plugins.filter(x => x.bootstrap).map(x => x.bootstrap)),
] ]
if (bootstrap.length == 0) {
throw new Error('Did not find any bootstrap components. Are there any plugins installed?')
}
@NgModule({ @NgModule({
imports, imports,
bootstrap, bootstrap,

View File

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

View File

@ -2,7 +2,7 @@
"compilerOptions": { "compilerOptions": {
"baseUrl": "./src", "baseUrl": "./src",
"module": "commonjs", "module": "commonjs",
"target": "es5", "target": "es2015",
"declaration": false, "declaration": false,
"noImplicitAny": false, "noImplicitAny": false,
"removeComments": false, "removeComments": false,

View File

@ -56,8 +56,8 @@
} }
}, },
"scripts": { "scripts": {
"build": "node --max-old-space-size=4096 ./node_modules/.bin/webpack --progress --color", "build": "webpack --progress --color",
"watch": "node --max-old-space-size=4096 ./node_modules/.bin/webpack --progress --color --watch", "watch": "webpack --progress --color --watch",
"pack": "build --dir", "pack": "build --dir",
"postinstall": "install-app-deps", "postinstall": "install-app-deps",
"dist": "build" "dist": "build"

View File

@ -17,7 +17,7 @@
}, },
"devDependencies": { "devDependencies": {
"@types/node": "7.0.12", "@types/node": "7.0.12",
"@types/webpack-env": "1.13.0", "@types/webpack-env": "^1.13.0",
"awesome-typescript-loader": "3.1.2", "awesome-typescript-loader": "3.1.2",
"raw-loader": "0.5.1", "raw-loader": "0.5.1",
"webpack": "2.3.3" "webpack": "2.3.3"

View File

@ -23,7 +23,5 @@
] ]
}, },
"compileOnSave": false, "compileOnSave": false,
"exclude": [ "include": ["src"]
"node_modules"
]
} }

View File

@ -23,13 +23,14 @@ module.exports = {
loader: 'awesome-typescript-loader', loader: 'awesome-typescript-loader',
options: { options: {
configFileName: path.resolve(__dirname, 'tsconfig.json'), configFileName: path.resolve(__dirname, 'tsconfig.json'),
typeRoots: [path.resolve(__dirname, 'node_modules/@types')],
paths: { paths: {
"terminus-*": [path.resolve(__dirname, '../terminus-*')], "terminus-*": [path.resolve(__dirname, '../terminus-*')],
"*": [path.resolve(__dirname, '../app/node_modules/*')], "*": [path.resolve(__dirname, '../app/node_modules/*')],
} }
} }
}, },
{ test: /\/schemes\//, loader: "raw-loader" }, { test: /[\\\/]schemes[\\\/]/, loader: "raw-loader" },
] ]
}, },
externals: [ externals: [

View File

@ -5,24 +5,27 @@
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"scripts": { "scripts": {
"build": "rm -r dist; webpack --progress --color --display-modules", "build": "rm -rf dist && webpack --progress --color --display-modules",
"watch": "rm -r dist; webpack --progress --color --watch" "watch": "rm -rf dist && webpack --progress --color --watch"
}, },
"author": "Eugene Pankov", "author": "Eugene Pankov",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"awesome-typescript-loader": "^3.1.2",
"angular2-toaster": "3.0.1",
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.22", "@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.22",
"typescript": "^2.2.2", "@types/electron": "^1.4.35",
"@types/js-yaml": "^3.5.29", "@types/js-yaml": "^3.5.29",
"webpack": "^2.3.3", "@types/node": "^7.0.12",
"@types/webpack-env": "^1.13.0",
"angular2-toaster": "3.0.1",
"awesome-typescript-loader": "^3.1.2",
"bootstrap": "4.0.0-alpha.6", "bootstrap": "4.0.0-alpha.6",
"core-js": "^2.4.1", "core-js": "^2.4.1",
"json-loader": "^0.5.4",
"ngx-perfect-scrollbar": "^4.0.0", "ngx-perfect-scrollbar": "^4.0.0",
"style-loader": "^0.13.1", "style-loader": "^0.13.1",
"to-string-loader": "^1.1.5", "to-string-loader": "^1.1.5",
"json-loader": "^0.5.4", "typescript": "^2.2.2",
"webpack": "^2.3.3",
"yaml-loader": "^0.4.0" "yaml-loader": "^0.4.0"
}, },
"peerDependencies": { "peerDependencies": {

View File

@ -12,7 +12,7 @@ $tabs-height: 40px;
overflow: hidden; overflow: hidden;
min-width: 0; min-width: 0;
transition: 0.25s all; transition: 0.25s ease-out all;
.wrapper { .wrapper {
display: flex; display: flex;

View File

@ -220,6 +220,14 @@ settings-tab > ngb-tabset {
padding: 10px 50px 10px 20px; padding: 10px 50px 10px 20px;
font-size: 14px; font-size: 14px;
&:not(.active) {
color: $body-color;
&:hover {
color: $white;
}
}
&.active { &.active {
border-top-color: $nav-tabs-active-link-hover-border-color; border-top-color: $nav-tabs-active-link-hover-border-color;
border-bottom-color: $nav-tabs-active-link-hover-border-color; border-bottom-color: $nav-tabs-active-link-hover-border-color;

View File

@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"baseUrl": "./src", "baseUrl": "src",
"module": "commonjs", "module": "commonjs",
"target": "es2015", "target": "es2015",
"declaration": false, "declaration": false,
@ -22,7 +22,5 @@
"es7" "es7"
] ]
}, },
"include": [ "include": ["src"]
"src"
]
} }

View File

@ -23,6 +23,7 @@ module.exports = {
loader: 'awesome-typescript-loader', loader: 'awesome-typescript-loader',
options: { options: {
configFileName: path.resolve(__dirname, 'tsconfig.json'), configFileName: path.resolve(__dirname, 'tsconfig.json'),
typeRoots: [path.resolve(__dirname, 'node_modules/@types')],
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

@ -22,7 +22,5 @@
"es7" "es7"
] ]
}, },
"include": [ "include": ["src"]
"src"
]
} }

View File

@ -23,6 +23,7 @@
"raw-loader": "^0.5.1", "raw-loader": "^0.5.1",
"sass-loader": "^6.0.3", "sass-loader": "^6.0.3",
"to-string-loader": "^1.1.5", "to-string-loader": "^1.1.5",
"typescript": "^2.2.2",
"webpack": "2.3.3" "webpack": "2.3.3"
}, },
"peerDependencies": { "peerDependencies": {

View File

@ -59,7 +59,7 @@
span &nbsp; span &nbsp;
span([style.color]='config.store.terminal.colorScheme.colors[15]') W span([style.color]='config.store.terminal.colorScheme.colors[15]') W
div div
span span &nbsp;
div div
span john@doe-pc span john@doe-pc
span([style.color]='config.store.terminal.colorScheme.colors[1]') $ span([style.color]='config.store.terminal.colorScheme.colors[1]') $
@ -76,7 +76,7 @@
span([style.color]='config.store.terminal.colorScheme.colors[2]') [emitted] span([style.color]='config.store.terminal.colorScheme.colors[2]') [emitted]
span([style.color]='config.store.terminal.colorScheme.colors[3]') [big] span([style.color]='config.store.terminal.colorScheme.colors[3]') [big]
div div
span span &nbsp;
div div
span john@doe-pc span john@doe-pc
span([style.color]='config.store.terminal.colorScheme.colors[1]') $ span([style.color]='config.store.terminal.colorScheme.colors[1]') $
@ -95,7 +95,7 @@
span -> span ->
span([style.color]='config.store.terminal.colorScheme.colors[1]') link span([style.color]='config.store.terminal.colorScheme.colors[1]') link
div div
span span &nbsp;
div div
span john@doe-pc span john@doe-pc
span([style.color]='config.store.terminal.colorScheme.colors[1]') $ span([style.color]='config.store.terminal.colorScheme.colors[1]') $
@ -187,22 +187,24 @@
type='radio', type='radio',
[value]='"theme"' [value]='"theme"'
) )
| From the app theme | From theme
label.btn.btn-secondary label.btn.btn-secondary
input( input(
type='radio', type='radio',
[value]='"colorScheme"' [value]='"colorScheme"'
) )
| From the terminal colors | From colors
.form-group .form-group
label Shell label Shell
input.form-control( select.form-control(
type='text',
[ngbTypeahead]='shellAutocomplete',
'[(ngModel)]'='config.store.terminal.shell', '[(ngModel)]'='config.store.terminal.shell',
(ngModelChange)='config.save()', (ngModelChange)='config.save()',
) )
option(
*ngFor='let shell of shells',
[ngValue]='shell.command'
) {{shell.name}}
.form-group .form-group
label Terminal bell label Terminal bell

View File

@ -10,13 +10,18 @@ import { ConfigService, HostAppService, Platform } from 'terminus-core'
import { TerminalColorSchemeProvider, ITerminalColorScheme } from '../api' import { TerminalColorSchemeProvider, ITerminalColorScheme } from '../api'
interface IShell {
name: string
command: string
}
@Component({ @Component({
template: require('./terminalSettingsTab.component.pug'), template: require('./terminalSettingsTab.component.pug'),
styles: [require('./terminalSettingsTab.component.scss')], styles: [require('./terminalSettingsTab.component.scss')],
}) })
export class TerminalSettingsTabComponent { export class TerminalSettingsTabComponent {
fonts: string[] = [] fonts: string[] = []
shells: string[] = [] shells: IShell[] = []
colorSchemes: ITerminalColorScheme[] = [] colorSchemes: ITerminalColorScheme[] = []
equalComparator = equal equalComparator = equal
editingColorScheme: ITerminalColorScheme editingColorScheme: ITerminalColorScheme
@ -44,11 +49,22 @@ export class TerminalSettingsTabComponent {
this.fonts.sort() this.fonts.sort()
}) })
} }
if (this.hostApp.platform == Platform.Windows) {
this.shells = [
{ name: 'CMD', command: 'cmd.exe' },
{ name: 'PowerShell', command: 'powershell.exe' },
]
const wslPath =`${process.env.windir}\\system32\\bash.exe`
if (await fs.exists(wslPath)) {
this.shells.push({ name: 'Bash on Windows', command: wslPath })
}
}
if (this.hostApp.platform == Platform.Linux || this.hostApp.platform == Platform.macOS) { if (this.hostApp.platform == Platform.Linux || this.hostApp.platform == Platform.macOS) {
this.shells = (await fs.readFile('/etc/shells', 'utf-8')) this.shells = (await fs.readFile('/etc/shells', 'utf-8'))
.split('\n') .split('\n')
.map(x => x.trim()) .map(x => x.trim())
.filter(x => x && !x.startsWith('#')) .filter(x => x && !x.startsWith('#'))
.map(x => ({ name: x, command: x }))
} }
this.colorSchemes = (await Promise.all(this.colorSchemeProviders.map(x => x.getSchemes()))).reduce((a, b) => a.concat(b)) this.colorSchemes = (await Promise.all(this.colorSchemeProviders.map(x => x.getSchemes()))).reduce((a, b) => a.concat(b))
} }
@ -61,10 +77,6 @@ export class TerminalSettingsTabComponent {
.map(list => Array.from(new Set(list))) .map(list => Array.from(new Set(list)))
} }
shellAutocomplete = (text$: Observable<string>) => {
return text$.map(_ => ['auto'].concat(this.shells))
}
editScheme (scheme: ITerminalColorScheme) { editScheme (scheme: ITerminalColorScheme) {
this.editingColorScheme = scheme this.editingColorScheme = scheme
this.schemeChanged = false this.schemeChanged = false

View File

@ -23,7 +23,7 @@ export class TerminalConfigProvider extends ConfigProvider {
[Platform.macOS]: { [Platform.macOS]: {
terminal: { terminal: {
font: 'Menlo', font: 'Menlo',
shell: 'zsh', shell: '/bin/zsh',
}, },
hotkeys: { hotkeys: {
'new-tab': [ 'new-tab': [
@ -49,7 +49,7 @@ export class TerminalConfigProvider extends ConfigProvider {
[Platform.Linux]: { [Platform.Linux]: {
terminal: { terminal: {
font: 'Liberation Mono', font: 'Liberation Mono',
shell: 'auto', shell: '/bin/bash',
}, },
hotkeys: { hotkeys: {
'new-tab': [ 'new-tab': [

View File

@ -22,8 +22,5 @@
"es7" "es7"
] ]
}, },
"compileOnSave": false, "include": ["src"]
"exclude": [
"node_modules"
]
} }

View File

@ -29,10 +29,9 @@ module.exports = {
} }
} }
}, },
{ test: /schemes\/.*$/, use: "raw-loader" },
{ test: /\.pug$/, use: ['apply-loader', 'pug-loader'] }, { test: /\.pug$/, use: ['apply-loader', 'pug-loader'] },
{ test: /\.scss$/, use: ['to-string-loader', 'css-loader', 'sass-loader'] }, { test: /\.scss$/, use: ['to-string-loader', 'css-loader', 'sass-loader'] },
{ test: /\.css$/, use: ['to-string-loader', 'css-loader', 'sass-loader'] }, { test: /\.css$/, use: ['to-string-loader', 'css-loader'] },
] ]
}, },
externals: [ externals: [

View File

@ -14,7 +14,5 @@
"es7" "es7"
] ]
}, },
"exclude": [ "include": ["src"]
"node_modules"
]
} }