From 919aa7c65f5ec85b469922f1a8f7f7be39fc5b12 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Mon, 17 Apr 2017 14:57:22 +0200 Subject: [PATCH] . --- Makefile | 6 +- app/src/app.module.ts | 4 ++ app/src/plugins.ts | 24 +++++--- app/tsconfig.json | 2 +- package.json | 4 +- terminus-community-color-schemes/package.json | 2 +- .../tsconfig.json | 4 +- .../webpack.config.js | 3 +- terminus-core/package.json | 17 +++--- .../src/components/tabHeader.component.scss | 2 +- terminus-core/src/theme.scss | 8 +++ terminus-core/tsconfig.json | 6 +- terminus-core/webpack.config.js | 1 + terminus-settings/tsconfig.json | 4 +- terminus-terminal/package.json | 1 + .../terminalSettingsTab.component.pug | 60 ++++++++++--------- .../terminalSettingsTab.component.ts | 22 +++++-- terminus-terminal/src/config.ts | 4 +- terminus-terminal/tsconfig.json | 5 +- terminus-terminal/webpack.config.js | 3 +- terminus-theme-hype/tsconfig.json | 4 +- 21 files changed, 108 insertions(+), 78 deletions(-) diff --git a/Makefile b/Makefile index abc39cc2..2dc63dce 100644 --- a/Makefile +++ b/Makefile @@ -21,9 +21,9 @@ install-deps: npm install npm prune for dir in app terminus-* ; do \ - cd $$dir; \ - npm --color always install 2>&1 | grep -v 'requires a peer'; \ - npm --color always prune 2>&1 | grep -v 'requires a peer'; \ + cd $$dir; \ + npm install; \ + npm prune; \ cd ..; \ done make build-native diff --git a/app/src/app.module.ts b/app/src/app.module.ts index 3096cb31..4e93e41a 100644 --- a/app/src/app.module.ts +++ b/app/src/app.module.ts @@ -14,6 +14,10 @@ export async function getRootModule(): Promise { ...(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({ imports, bootstrap, diff --git a/app/src/plugins.ts b/app/src/plugins.ts index 2b518ebe..b123f84a 100644 --- a/app/src/plugins.ts +++ b/app/src/plugins.ts @@ -1,26 +1,36 @@ import * as fs from 'fs-promise' import * as path from 'path' +const nodeModule = (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 +}; + +(global).require.main.paths.map(x => nodeModule.globalPaths.push(normalizePath(x))) -let nodeRequire = (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.unshift(x)) + process.env.TERMINUS_PLUGINS.split(':').map(x => nodeModule.globalPaths.unshift(normalizePath(x))) } export async function loadPlugins (): Promise { - let paths = module.globalPaths + let paths = nodeModule.globalPaths let plugins: any[] = [] for (let pluginDir of paths) { + pluginDir = normalizePath(pluginDir) 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)}`) + console.info(`Loading ${pluginName}: ${(global).require.resolve(pluginPath)}`) try { - let pluginModule = nodeRequire(pluginPath) + let pluginModule = (global).require(pluginPath) plugins.push(pluginModule) } catch (error) { console.error(`Could not load ${pluginName}:`, error) diff --git a/app/tsconfig.json b/app/tsconfig.json index 7d9d1fbe..34b7b7e7 100644 --- a/app/tsconfig.json +++ b/app/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "baseUrl": "./src", "module": "commonjs", - "target": "es5", + "target": "es2015", "declaration": false, "noImplicitAny": false, "removeComments": false, diff --git a/package.json b/package.json index f91dabe2..bd436100 100644 --- a/package.json +++ b/package.json @@ -56,8 +56,8 @@ } }, "scripts": { - "build": "node --max-old-space-size=4096 ./node_modules/.bin/webpack --progress --color", - "watch": "node --max-old-space-size=4096 ./node_modules/.bin/webpack --progress --color --watch", + "build": "webpack --progress --color", + "watch": "webpack --progress --color --watch", "pack": "build --dir", "postinstall": "install-app-deps", "dist": "build" diff --git a/terminus-community-color-schemes/package.json b/terminus-community-color-schemes/package.json index a01924fe..24312f75 100644 --- a/terminus-community-color-schemes/package.json +++ b/terminus-community-color-schemes/package.json @@ -17,7 +17,7 @@ }, "devDependencies": { "@types/node": "7.0.12", - "@types/webpack-env": "1.13.0", + "@types/webpack-env": "^1.13.0", "awesome-typescript-loader": "3.1.2", "raw-loader": "0.5.1", "webpack": "2.3.3" diff --git a/terminus-community-color-schemes/tsconfig.json b/terminus-community-color-schemes/tsconfig.json index f27292c3..119f34fb 100644 --- a/terminus-community-color-schemes/tsconfig.json +++ b/terminus-community-color-schemes/tsconfig.json @@ -23,7 +23,5 @@ ] }, "compileOnSave": false, - "exclude": [ - "node_modules" - ] + "include": ["src"] } diff --git a/terminus-community-color-schemes/webpack.config.js b/terminus-community-color-schemes/webpack.config.js index b1bca705..47d10feb 100644 --- a/terminus-community-color-schemes/webpack.config.js +++ b/terminus-community-color-schemes/webpack.config.js @@ -23,13 +23,14 @@ module.exports = { loader: 'awesome-typescript-loader', options: { configFileName: path.resolve(__dirname, 'tsconfig.json'), + typeRoots: [path.resolve(__dirname, 'node_modules/@types')], paths: { "terminus-*": [path.resolve(__dirname, '../terminus-*')], "*": [path.resolve(__dirname, '../app/node_modules/*')], } } }, - { test: /\/schemes\//, loader: "raw-loader" }, + { test: /[\\\/]schemes[\\\/]/, loader: "raw-loader" }, ] }, externals: [ diff --git a/terminus-core/package.json b/terminus-core/package.json index ccbca969..74d1b6ee 100644 --- a/terminus-core/package.json +++ b/terminus-core/package.json @@ -5,24 +5,27 @@ "main": "dist/index.js", "typings": "dist/index.d.ts", "scripts": { - "build": "rm -r dist; webpack --progress --color --display-modules", - "watch": "rm -r dist; webpack --progress --color --watch" + "build": "rm -rf dist && webpack --progress --color --display-modules", + "watch": "rm -rf dist && webpack --progress --color --watch" }, "author": "Eugene Pankov", "license": "MIT", "devDependencies": { - "awesome-typescript-loader": "^3.1.2", - "angular2-toaster": "3.0.1", "@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.22", - "typescript": "^2.2.2", + "@types/electron": "^1.4.35", "@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", "core-js": "^2.4.1", + "json-loader": "^0.5.4", "ngx-perfect-scrollbar": "^4.0.0", "style-loader": "^0.13.1", "to-string-loader": "^1.1.5", - "json-loader": "^0.5.4", + "typescript": "^2.2.2", + "webpack": "^2.3.3", "yaml-loader": "^0.4.0" }, "peerDependencies": { diff --git a/terminus-core/src/components/tabHeader.component.scss b/terminus-core/src/components/tabHeader.component.scss index af337c43..c8802088 100644 --- a/terminus-core/src/components/tabHeader.component.scss +++ b/terminus-core/src/components/tabHeader.component.scss @@ -12,7 +12,7 @@ $tabs-height: 40px; overflow: hidden; min-width: 0; - transition: 0.25s all; + transition: 0.25s ease-out all; .wrapper { display: flex; diff --git a/terminus-core/src/theme.scss b/terminus-core/src/theme.scss index 574b6488..14625afd 100644 --- a/terminus-core/src/theme.scss +++ b/terminus-core/src/theme.scss @@ -220,6 +220,14 @@ settings-tab > ngb-tabset { padding: 10px 50px 10px 20px; font-size: 14px; + &:not(.active) { + color: $body-color; + + &:hover { + color: $white; + } + } + &.active { border-top-color: $nav-tabs-active-link-hover-border-color; border-bottom-color: $nav-tabs-active-link-hover-border-color; diff --git a/terminus-core/tsconfig.json b/terminus-core/tsconfig.json index 11240889..98612ad0 100644 --- a/terminus-core/tsconfig.json +++ b/terminus-core/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": "./src", + "baseUrl": "src", "module": "commonjs", "target": "es2015", "declaration": false, @@ -22,7 +22,5 @@ "es7" ] }, - "include": [ - "src" - ] + "include": ["src"] } diff --git a/terminus-core/webpack.config.js b/terminus-core/webpack.config.js index 06e6adeb..7060693c 100644 --- a/terminus-core/webpack.config.js +++ b/terminus-core/webpack.config.js @@ -23,6 +23,7 @@ module.exports = { loader: 'awesome-typescript-loader', options: { configFileName: path.resolve(__dirname, 'tsconfig.json'), + typeRoots: [path.resolve(__dirname, 'node_modules/@types')], paths: { "terminus-*": [path.resolve(__dirname, '../terminus-*')], "*": [path.resolve(__dirname, '../app/node_modules/*')], diff --git a/terminus-settings/tsconfig.json b/terminus-settings/tsconfig.json index 11240889..26325f73 100644 --- a/terminus-settings/tsconfig.json +++ b/terminus-settings/tsconfig.json @@ -22,7 +22,5 @@ "es7" ] }, - "include": [ - "src" - ] + "include": ["src"] } diff --git a/terminus-terminal/package.json b/terminus-terminal/package.json index e5d26ce9..a7f7e0e8 100644 --- a/terminus-terminal/package.json +++ b/terminus-terminal/package.json @@ -23,6 +23,7 @@ "raw-loader": "^0.5.1", "sass-loader": "^6.0.3", "to-string-loader": "^1.1.5", + "typescript": "^2.2.2", "webpack": "2.3.3" }, "peerDependencies": { diff --git a/terminus-terminal/src/components/terminalSettingsTab.component.pug b/terminus-terminal/src/components/terminalSettingsTab.component.pug index 1ae23c40..ab915358 100644 --- a/terminus-terminal/src/components/terminalSettingsTab.component.pug +++ b/terminus-terminal/src/components/terminalSettingsTab.component.pug @@ -8,7 +8,7 @@ [style.background-color]='(config.store.terminal.background == "theme") ? null : config.store.terminal.colorScheme.background', [style.color]='config.store.terminal.colorScheme.foreground', ) - div + div span([style.background-color]='config.store.terminal.colorScheme.colors[0]')   span([style.background-color]='config.store.terminal.colorScheme.colors[1]')   span([style.background-color]='config.store.terminal.colorScheme.colors[2]')   @@ -33,7 +33,7 @@ span([style.color]='config.store.terminal.colorScheme.colors[6]') T span   span([style.color]='config.store.terminal.colorScheme.colors[7]') W - div + div span([style.background-color]='config.store.terminal.colorScheme.colors[8]')   span([style.background-color]='config.store.terminal.colorScheme.colors[9]')   span([style.background-color]='config.store.terminal.colorScheme.colors[10]')   @@ -58,51 +58,51 @@ span([style.color]='config.store.terminal.colorScheme.colors[14]') T span   span([style.color]='config.store.terminal.colorScheme.colors[15]') W - div - span - div + div + span   + div span john@doe-pc span([style.color]='config.store.terminal.colorScheme.colors[1]') $ span webpack - div + div span Asset Size - div - span([style.color]='config.store.terminal.colorScheme.colors[2]') main.js + div + span([style.color]='config.store.terminal.colorScheme.colors[2]') main.js span 234 kB span([style.color]='config.store.terminal.colorScheme.colors[2]') [emitted] - div - span([style.color]='config.store.terminal.colorScheme.colors[3]') big.js + div + span([style.color]='config.store.terminal.colorScheme.colors[3]') big.js span([style.color]='config.store.terminal.colorScheme.colors[3]') 1.2 MB span([style.color]='config.store.terminal.colorScheme.colors[2]') [emitted] span([style.color]='config.store.terminal.colorScheme.colors[3]') [big] div - span - div + span   + div span john@doe-pc span([style.color]='config.store.terminal.colorScheme.colors[1]') $ span ls -l - div + div span drwxr-xr-x 1 root span([style.color]='config.store.terminal.colorScheme.colors[4]') directory - div + div span -rw-r--r-- 1 root file - div + div span -rwxr-xr-x 1 root span([style.color]='config.store.terminal.colorScheme.colors[2]') executable - div + div span -rwxr-xr-x 1 root span([style.color]='config.store.terminal.colorScheme.colors[6]') sym span -> span([style.color]='config.store.terminal.colorScheme.colors[1]') link div - span - div + span   + div span john@doe-pc span([style.color]='config.store.terminal.colorScheme.colors[1]') $ span rm -rf / span([style.background-color]='config.store.terminal.colorScheme.cursor')   - - + + .col-md-6 .form-group label Font @@ -136,11 +136,11 @@ button.btn.btn-secondary((click)='editScheme(config.store.terminal.colorScheme)') Edit .input-group-btn button.btn.btn-outline-danger( - (click)='deleteScheme(config.store.terminal.colorScheme)', + (click)='deleteScheme(config.store.terminal.colorScheme)', *ngIf='isCustomScheme(config.store.terminal.colorScheme)' ) i.fa.fa-trash-o - + .form-group(*ngIf='editingColorScheme') label Editing .input-group @@ -149,7 +149,7 @@ button.btn.btn-secondary((click)='saveScheme()') Save .input-group-btn button.btn.btn-secondary((click)='cancelEditing()') Cancel - + .form-group(*ngIf='editingColorScheme') color-picker( @@ -187,23 +187,25 @@ type='radio', [value]='"theme"' ) - | From the app theme + | From theme label.btn.btn-secondary input( type='radio', [value]='"colorScheme"' ) - | From the terminal colors + | From colors .form-group label Shell - input.form-control( - type='text', - [ngbTypeahead]='shellAutocomplete', + select.form-control( '[(ngModel)]'='config.store.terminal.shell', (ngModelChange)='config.save()', ) - + option( + *ngFor='let shell of shells', + [ngValue]='shell.command' + ) {{shell.name}} + .form-group label Terminal bell br diff --git a/terminus-terminal/src/components/terminalSettingsTab.component.ts b/terminus-terminal/src/components/terminalSettingsTab.component.ts index 13ab6cae..6af49054 100644 --- a/terminus-terminal/src/components/terminalSettingsTab.component.ts +++ b/terminus-terminal/src/components/terminalSettingsTab.component.ts @@ -10,13 +10,18 @@ import { ConfigService, HostAppService, Platform } from 'terminus-core' import { TerminalColorSchemeProvider, ITerminalColorScheme } from '../api' +interface IShell { + name: string + command: string +} + @Component({ template: require('./terminalSettingsTab.component.pug'), styles: [require('./terminalSettingsTab.component.scss')], }) export class TerminalSettingsTabComponent { fonts: string[] = [] - shells: string[] = [] + shells: IShell[] = [] colorSchemes: ITerminalColorScheme[] = [] equalComparator = equal editingColorScheme: ITerminalColorScheme @@ -44,11 +49,22 @@ export class TerminalSettingsTabComponent { 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) { this.shells = (await fs.readFile('/etc/shells', 'utf-8')) .split('\n') .map(x => x.trim()) .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)) } @@ -61,10 +77,6 @@ export class TerminalSettingsTabComponent { .map(list => Array.from(new Set(list))) } - shellAutocomplete = (text$: Observable) => { - return text$.map(_ => ['auto'].concat(this.shells)) - } - editScheme (scheme: ITerminalColorScheme) { this.editingColorScheme = scheme this.schemeChanged = false diff --git a/terminus-terminal/src/config.ts b/terminus-terminal/src/config.ts index cb8146c5..b2310b21 100644 --- a/terminus-terminal/src/config.ts +++ b/terminus-terminal/src/config.ts @@ -23,7 +23,7 @@ export class TerminalConfigProvider extends ConfigProvider { [Platform.macOS]: { terminal: { font: 'Menlo', - shell: 'zsh', + shell: '/bin/zsh', }, hotkeys: { 'new-tab': [ @@ -49,7 +49,7 @@ export class TerminalConfigProvider extends ConfigProvider { [Platform.Linux]: { terminal: { font: 'Liberation Mono', - shell: 'auto', + shell: '/bin/bash', }, hotkeys: { 'new-tab': [ diff --git a/terminus-terminal/tsconfig.json b/terminus-terminal/tsconfig.json index f27292c3..98612ad0 100644 --- a/terminus-terminal/tsconfig.json +++ b/terminus-terminal/tsconfig.json @@ -22,8 +22,5 @@ "es7" ] }, - "compileOnSave": false, - "exclude": [ - "node_modules" - ] + "include": ["src"] } diff --git a/terminus-terminal/webpack.config.js b/terminus-terminal/webpack.config.js index acd92e6d..406a4b9e 100644 --- a/terminus-terminal/webpack.config.js +++ b/terminus-terminal/webpack.config.js @@ -29,10 +29,9 @@ module.exports = { } } }, - { test: /schemes\/.*$/, use: "raw-loader" }, { test: /\.pug$/, use: ['apply-loader', 'pug-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: [ diff --git a/terminus-theme-hype/tsconfig.json b/terminus-theme-hype/tsconfig.json index 30cc8829..e5b78343 100644 --- a/terminus-theme-hype/tsconfig.json +++ b/terminus-theme-hype/tsconfig.json @@ -14,7 +14,5 @@ "es7" ] }, - "exclude": [ - "node_modules" - ] + "include": ["src"] }