From 5e2dae153e2fced5f83f3fd4965ff5ff67105e02 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Tue, 20 Jun 2017 23:28:58 +0200 Subject: [PATCH] wip --- HACKING.md | 115 ++++++++++++++++++ LICENSE | 21 ++++ app/src/entry.ts | 2 +- app/webpack.config.js | 5 +- package-lock.json | 26 ---- package.json | 78 ++++++------ scripts/install-deps.js | 5 + terminus-community-color-schemes/package.json | 5 +- .../webpack.config.js | 6 +- terminus-core/package.json | 10 +- terminus-core/webpack.config.js | 6 +- terminus-plugin-manager/package.json | 13 +- terminus-plugin-manager/webpack.config.js | 6 +- terminus-settings/package.json | 11 +- terminus-settings/webpack.config.js | 6 +- terminus-terminal/package.json | 11 +- terminus-terminal/webpack.config.js | 6 +- 17 files changed, 217 insertions(+), 115 deletions(-) create mode 100644 HACKING.md create mode 100644 LICENSE diff --git a/HACKING.md b/HACKING.md new file mode 100644 index 00000000..fbe951f3 --- /dev/null +++ b/HACKING.md @@ -0,0 +1,115 @@ +# Some background + +Terminus is an Electron app, with the frontend written in Typescript with the help of Angular framework. It's built using Webpack. + +# Getting started + +First of all, clone this repository. You'll also need a recent version of Node installed. + +First, install the dependencies: + +``` +# macOS/Linux: +npm i +./scripts/install-deps.js +./scripts/build-native.js + +# Windows: +npm i +node scripts\install-deps.js +node scripts\build-native.js +``` + +Now, check if your build is working: + +``` +npm run build +``` + +Start Terminus with + +``` +npm start +``` + +# Project layout +``` +terminus +├─ app # Electron app, just the bare essentials +| ├─ src # Electron renderer code +| └─ main.js # Electron main entry point +├─ build +├─ clink # Clink distributive, for Windows +├─ scripts # Maintenance scripts +├─ terminus-community-color-schemes # Plugin that provides color schemes +├─ terminus-core # Plugin that provides base UI and tab management +├─ terminus-plugin-manager # Plugin that installs other plugins +├─ terminus-settings # Plugin that provides the settings tab +└─ terminus-terminal # Plugin that provides terminal tabs +``` + +# Plugin layout +``` +terminus-pluginname +├─ src # Typescript code +| ├─ components # Angular components +| | ├─ foo.component.ts # Code +| | ├─ foo.component.scss # Styles +| | └─ foo.component.pug # Template +| ├─ services # Angular services +| | └─ foo.service.ts +| ├─ api.ts # Publicly exported API +| └─ index.ts # Module entry point +├─ package.json +├─ tsconfig.json +└─ webpack.config.js +``` + +# Plugins + +The app will load all plugins from the source checkout in the dev mode, and from the user's plugins directory at all times (click `Open Plugins Directory` under `Settings` > `Plugins`). + +A plugin should only provide a default export, which should be a `NgModule` class (or a `NgModuleWithDependencies` where applicable). This module will be injected as a dependency to the app's root module. + +```javascript +import { NgModule } from '@angular/core' + +@NgModule() +export default class MyModule { + constructor () { + console.log('Angular engaged, cap\'n.') + } +} +``` + +Plugins provide functionality by exporting singular or multi providers: + + +```javascript +import { NgModule, Injectable } from '@angular/core' +import { ToolbarButtonProvider, IToolbarButton } from 'terminus-core' + +@Injectable() +export class MyButtonProvider extends ToolbarButtonProvider { + provide (): IToolbarButton[] { + return [{ + icon: 'star', + title: 'Foobar', + weight: 10, + click: () => { + alert('Woohoo!') + } + }] + } +} + +@NgModule({ + providers: [ + { provide: ToolbarButtonProvider, useClass: MyButtonProvider, multi: true }, + ], +}) +export default class MyModule { } +``` + + +See `terminus-core/src/api.ts`, `terminus-settings/src/api.ts` and `terminus-terminal/src/api.ts` for the available extension points. diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..d96a83ef --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 Eugene Pankov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/app/src/entry.ts b/app/src/entry.ts index 993cc76e..6ece8d1b 100644 --- a/app/src/entry.ts +++ b/app/src/entry.ts @@ -1,6 +1,6 @@ -import 'core-js' import 'zone.js/dist/zone.js' import 'core-js/es7/reflect' +import 'core-js/core/delay' import 'rxjs' // Always land on the start view diff --git a/app/webpack.config.js b/app/webpack.config.js index 157ff05b..8101f54d 100644 --- a/app/webpack.config.js +++ b/app/webpack.config.js @@ -62,5 +62,8 @@ module.exports = { 'path': 'commonjs path', 'rxjs': 'commonjs rxjs', 'zone.js': 'commonjs zone.js', - } + }, + plugins: [ + new webpack.optimize.ModuleConcatenationPlugin(), + ], } diff --git a/package-lock.json b/package-lock.json index ca9691cd..71b490de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,18 +27,6 @@ "integrity": "sha1-JeTdgEtjDJFq5nEjPm1x9s4YEko=", "dev": true }, - "@types/raven": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@types/raven/-/raven-1.2.2.tgz", - "integrity": "sha1-r+Ur2YGHo6PSi4IS42MUO9FvI78=", - "dev": true - }, - "@types/raven-js": { - "version": "3.10.0", - "resolved": "https://registry.npmjs.org/@types/raven-js/-/raven-js-3.10.0.tgz", - "integrity": "sha1-0IMhYuvqdnHq//CKMktWrd5b+cM=", - "dev": true - }, "@types/webpack-env": { "version": "https://registry.npmjs.org/@types/webpack-env/-/webpack-env-1.13.0.tgz", "integrity": "sha1-MEQ4FkfhHulzxa8uklMjkw9pHYA=", @@ -2780,20 +2768,6 @@ "integrity": "sha1-Z0yZdgkBw8QRJ3GjHlIdw0nMCew=", "dev": true }, - "raven": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/raven/-/raven-2.0.2.tgz", - "integrity": "sha1-pD07hwKubbLpGYdii+jyiVAIEK4=", - "dev": true, - "dependencies": { - "uuid": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.0.tgz", - "integrity": "sha1-Zyj8BFnEUNeWqZwxg3VpvfZy1yg=", - "dev": true - } - } - }, "raven-js": { "version": "3.16.0", "resolved": "https://registry.npmjs.org/raven-js/-/raven-js-3.16.0.tgz", diff --git a/package.json b/package.json index 34146dc7..bb2f9721 100644 --- a/package.json +++ b/package.json @@ -1,50 +1,50 @@ { "name": "term", "devDependencies": { - "@types/core-js": "^0.9.35", + "@types/core-js": "0.9.35", "@types/electron": "1.4.34", - "@types/fs-promise": "^1.0.1", - "@types/node": "^7.0.5", - "@types/raven": "^1.2.2", - "@types/raven-js": "^3.10.0", - "@types/webpack-env": "^1.13.0", - "apply-loader": "^0.1.0", + "@types/fs-promise": "1.0.1", + "@types/node": "7.0.5", + "@types/webpack-env": "1.13.0", + "apply-loader": "0.1.0", "awesome-typescript-loader": "3.1.2", - "core-js": "^2.4.1", - "cross-env": "^4.0.0", - "css-loader": "0.26.1", - "electron": "1.7.2", - "electron-builder": "^17.1.1", - "electron-builder-squirrel-windows": "^17.0.1", + "core-js": "2.4.1", + "cross-env": "4.0.0", + "css-loader": "0.28.0", + "electron-builder-squirrel-windows": "17.0.1", + "electron-builder": "17.1.1", "electron-osx-sign": "electron-userland/electron-osx-sign#f092181a1bffa2b3248a23ee28447a47e14a8f04", - "electron-rebuild": "^1.5.11", - "file-loader": "^0.9.0", + "electron-rebuild": "1.5.11", + "electron": "1.7.2", + "file-loader": "0.9.0", "font-awesome": "4.7.0", - "html-loader": "^0.4.4", - "less": "^2.7.1", - "less-loader": "^2.2.3", - "node-abi": "^2.0.3", - "node-gyp": "^3.4.0", - "node-sass": "^4.5.0", - "npmlog": "^4.1.0", - "pug-html-loader": "^1.0.9", - "pug-loader": "^2.3.0", + "html-loader": "0.4.4", + "json-loader": "0.5.4", + "less-loader": "2.2.3", + "less": "2.7.1", + "node-abi": "2.0.3", + "node-gyp": "3.4.0", + "node-sass": "4.5.2", + "npmlog": "4.1.0", + "pug-html-loader": "1.0.9", + "pug-loader": "2.3.0", "pug-static-loader": "0.0.1", - "raven": "^2.0.2", - "raven-js": "^3.16.0", - "raw-loader": "^0.5.1", - "sass-loader": "^6.0.3", - "shelljs": "^0.7.7", - "source-sans-pro": "^2.0.10", - "style-loader": "^0.13.1", - "to-string-loader": "^1.1.5", - "tslint": "^5.1.0", - "tslint-config-standard": "^5.0.2", - "tslint-eslint-rules": "^4.0.0", - "typescript": "~2.1.0", - "url-loader": "^0.5.7", - "val-loader": "^0.5.0", - "webpack": "2.4.1" + "pug": "2.0.0-beta11", + "raven-js": "3.16.0", + "raw-loader": "0.5.1", + "sass-loader": "6.0.3", + "shelljs": "0.7.7", + "source-sans-pro": "2.0.10", + "style-loader": "0.13.1", + "to-string-loader": "1.1.5", + "tslint-config-standard": "5.0.2", + "tslint-eslint-rules": "4.0.0", + "tslint": "5.1.0", + "typescript": "2.2.2", + "url-loader": "0.5.7", + "val-loader": "0.5.0", + "yaml-loader": "0.4.0", + "webpack": "3.0.0" }, "build": { "appId": "org.terminus", diff --git a/scripts/install-deps.js b/scripts/install-deps.js index b9e1c272..7f48b325 100755 --- a/scripts/install-deps.js +++ b/scripts/install-deps.js @@ -8,6 +8,11 @@ log.info('deps', 'app') sh.exec('npm prune') sh.exec('npm install') +sh.cd('app') +sh.exec('npm prune') +sh.exec('npm install') +sh.cd('..') + vars.builtinPlugins.forEach(plugin => { log.info('deps', plugin) sh.cd(plugin) diff --git a/terminus-community-color-schemes/package.json b/terminus-community-color-schemes/package.json index 5b545470..49ba376e 100644 --- a/terminus-community-color-schemes/package.json +++ b/terminus-community-color-schemes/package.json @@ -20,10 +20,7 @@ }, "devDependencies": { "@types/node": "7.0.12", - "@types/webpack-env": "^1.13.0", - "awesome-typescript-loader": "3.1.2", - "raw-loader": "0.5.1", - "webpack": "2.3.3" + "@types/webpack-env": "^1.13.0" }, "false": {} } diff --git a/terminus-community-color-schemes/webpack.config.js b/terminus-community-color-schemes/webpack.config.js index 47d10feb..1a5d51b5 100644 --- a/terminus-community-color-schemes/webpack.config.js +++ b/terminus-community-color-schemes/webpack.config.js @@ -1,4 +1,5 @@ const path = require('path') +const webpack = require('webpack') module.exports = { target: 'node', @@ -38,5 +39,8 @@ module.exports = { /^@angular/, /^@ng-bootstrap/, /^terminus-/, - ] + ], + plugins: [ + new webpack.optimize.ModuleConcatenationPlugin(), + ], } diff --git a/terminus-core/package.json b/terminus-core/package.json index 21dc371b..5a1528b9 100644 --- a/terminus-core/package.json +++ b/terminus-core/package.json @@ -19,16 +19,10 @@ "@types/js-yaml": "^3.5.29", "@types/node": "^7.0.12", "@types/webpack-env": "^1.13.0", - "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", - "typescript": "^2.2.2", - "webpack": "^2.3.3", - "yaml-loader": "^0.4.0" + "ngx-perfect-scrollbar": "4.0.0", + "typescript": "^2.2.2" }, "peerDependencies": { "@angular/animations": "4.0.1", diff --git a/terminus-core/webpack.config.js b/terminus-core/webpack.config.js index 7060693c..6175bf0a 100644 --- a/terminus-core/webpack.config.js +++ b/terminus-core/webpack.config.js @@ -1,4 +1,5 @@ const path = require('path') +const webpack = require('webpack') module.exports = { target: 'node', @@ -48,5 +49,8 @@ module.exports = { /^rxjs/, /^@angular/, /^@ng-bootstrap/, - ] + ], + plugins: [ + new webpack.optimize.ModuleConcatenationPlugin(), + ], } diff --git a/terminus-plugin-manager/package.json b/terminus-plugin-manager/package.json index 2a626398..8fe3107f 100644 --- a/terminus-plugin-manager/package.json +++ b/terminus-plugin-manager/package.json @@ -16,20 +16,11 @@ "devDependencies": { "@types/mz": "0.0.31", "@types/node": "7.0.12", - "@types/npm": "^2.0.28", "@types/semver": "^5.3.31", "@types/webpack-env": "1.13.0", - "awesome-typescript-loader": "3.1.2", - "css-loader": "^0.28.0", "ngx-pipes": "^1.6.1", - "pug": "^2.0.0-beta11", - "pug-loader": "^2.3.0", - "raw-loader": "^0.5.1", - "sass-loader": "^6.0.3", - "semver": "^5.3.0", - "to-string-loader": "^1.1.5", - "typescript": "^2.2.2", - "webpack": "2.3.3" + "css-loader": "^0.28.0", + "semver": "^5.3.0" }, "peerDependencies": { "@angular/common": "4.0.1", diff --git a/terminus-plugin-manager/webpack.config.js b/terminus-plugin-manager/webpack.config.js index 0e4f0448..78a34509 100644 --- a/terminus-plugin-manager/webpack.config.js +++ b/terminus-plugin-manager/webpack.config.js @@ -1,4 +1,5 @@ const path = require('path') +const webpack = require('webpack') module.exports = { target: 'node', @@ -45,5 +46,8 @@ module.exports = { /^@angular/, /^@ng-bootstrap/, /^terminus-/, - ] + ], + plugins: [ + new webpack.optimize.ModuleConcatenationPlugin(), + ], } diff --git a/terminus-settings/package.json b/terminus-settings/package.json index 75f702e7..724dd5d9 100644 --- a/terminus-settings/package.json +++ b/terminus-settings/package.json @@ -17,16 +17,7 @@ "@types/deep-equal": "1.0.0", "@types/node": "7.0.12", "@types/webpack-env": "1.13.0", - "awesome-typescript-loader": "3.1.2", - "css-loader": "^0.28.0", - "ngx-pipes": "^1.6.1", - "node-sass": "^4.5.2", - "pug": "^2.0.0-beta3", - "pug-loader": "^2.3.0", - "raw-loader": "^0.5.1", - "sass-loader": "^6.0.3", - "to-string-loader": "^1.1.5", - "webpack": "2.3.3" + "ngx-pipes": "^1.6.1" }, "peerDependencies": { "@angular/common": "4.0.1", diff --git a/terminus-settings/webpack.config.js b/terminus-settings/webpack.config.js index a2174e6d..41b54289 100644 --- a/terminus-settings/webpack.config.js +++ b/terminus-settings/webpack.config.js @@ -1,4 +1,5 @@ const path = require('path') +const webpack = require('webpack') module.exports = { target: 'node', @@ -44,5 +45,8 @@ module.exports = { /^@angular/, /^@ng-bootstrap/, /^terminus-/, - ] + ], + plugins: [ + new webpack.optimize.ModuleConcatenationPlugin(), + ], } diff --git a/terminus-terminal/package.json b/terminus-terminal/package.json index 073d2125..3f8b1f7f 100644 --- a/terminus-terminal/package.json +++ b/terminus-terminal/package.json @@ -19,17 +19,8 @@ "@types/node": "7.0.12", "@types/webpack-env": "1.13.0", "@types/winreg": "^1.2.30", - "awesome-typescript-loader": "3.1.2", - "css-loader": "^0.28.0", "dataurl": "0.1.0", - "deep-equal": "1.0.1", - "pug": "^2.0.0-beta11", - "pug-loader": "^2.3.0", - "raw-loader": "^0.5.1", - "sass-loader": "^6.0.3", - "to-string-loader": "^1.1.5", - "typescript": "^2.2.2", - "webpack": "2.3.3" + "deep-equal": "1.0.1" }, "peerDependencies": { "@angular/common": "4.0.1", diff --git a/terminus-terminal/webpack.config.js b/terminus-terminal/webpack.config.js index 96d52e5d..e7f609f7 100644 --- a/terminus-terminal/webpack.config.js +++ b/terminus-terminal/webpack.config.js @@ -1,4 +1,5 @@ const path = require('path') +const webpack = require('webpack') module.exports = { target: 'node', @@ -46,5 +47,8 @@ module.exports = { /^@angular/, /^@ng-bootstrap/, /^terminus-/, - ] + ], + plugins: [ + new webpack.optimize.ModuleConcatenationPlugin(), + ], } -- GitLab