Skip to content
This repository has been archived by the owner on Jun 5, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1 from kwonoj/feat-ng2-example
Browse files Browse the repository at this point in the history
Angular2 example
  • Loading branch information
anaisbetts authored Dec 30, 2016
2 parents 51e36f9 + aa15353 commit e80e069
Show file tree
Hide file tree
Showing 10 changed files with 272 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
out
45 changes: 45 additions & 0 deletions angular2/.compilerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"env": {
"development": {
"text/typescript": {
"removeComments": false,
"preserveConstEnums": true,
"declaration": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"noImplicitThis": true,
"noUnusedParameters": true,
"inlineSourceMap": true,
"inlineSources": true,
"importHelpers": true,
"noEmitHelpers": true,
"experimentalDecorators": true,
"target": "es2015",
"doSemanticChecks": false
}
},
"production": {
"text/typescript": {
"removeComments": false,
"preserveConstEnums": true,
"declaration": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"noImplicitThis": true,
"noUnusedParameters": true,
"sourceMap": false,
"importHelpers": true,
"noEmitHelpers": true,
"experimentalDecorators": true,
"target": "es2015",
"doSemanticChecks": false
}
}
}
}
3 changes: 3 additions & 0 deletions angular2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
out
npm-debug.log
54 changes: 54 additions & 0 deletions angular2/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "angular2-starter",
"productName": "angular2-starter",
"version": "1.0.0",
"description": "Angular2 basic example application",
"main": "src/index.ts",
"scripts": {
"start": "electron-forge start",
"lint": "tslint src"
},
"keywords": [],
"author": "Fill in your name here!",
"license": "MIT",
"config": {
"forge": {
"make_targets": {
"win32": [
"squirrel"
],
"darwin": [
"zip"
],
"linux": [
"deb",
"rpm"
]
},
"electronPackagerConfig": {},
"electronWinstallerConfig": {
"name": "test"
},
"electronInstallerDebian": {},
"electronInstallerRedhat": {}
}
},
"dependencies": {
"@angular/common": "^2.4.1",
"@angular/compiler": "^2.4.1",
"@angular/core": "^2.4.1",
"@angular/platform-browser": "^2.4.1",
"@angular/platform-browser-dynamic": "^2.4.1",
"@types/electron": "^1.4.30",
"electron-compile": "^5.1.0",
"reflect-metadata": "^0.1.9",
"tslib": "^1.4.0",
"zone.js": "^0.7.4"
},
"devDependencies": {
"electron-devtools-installer": "^2.0.1",
"electron-prebuilt-compile": "1.4.12",
"tslint": "^4.2.0",
"typescript": "^2.1.4"
}
}
25 changes: 25 additions & 0 deletions angular2/src/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'App',
template:
`<div>
<h2>Welcome to {{name}} Angular2!</h2>
</div>`
})
export class AppComponent implements OnInit {
public readonly name = 'electron-forge';

ngOnInit(): void {
console.log('component initialized');
}
}

@NgModule({
imports: [BrowserModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
7 changes: 7 additions & 0 deletions angular2/src/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'zone.js';
import 'reflect-metadata';

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.component';

platformBrowserDynamic().bootstrapModule(AppModule);
10 changes: 10 additions & 0 deletions angular2/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
</head>
<body style="overflow: hidden; background-color: rgba(0,0,0,0); margin: 0" >
<App/>
</body>
<script src="bootstrap.ts"></script>
</html>
56 changes: 56 additions & 0 deletions angular2/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { app, BrowserWindow } from 'electron';

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow: Electron.BrowserWindow | null;

const isDevMode = process.execPath.match(/[\\/]electron/);

const createWindow = async () => {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 600,
});

// and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/index.html`);

// Open the DevTools.
if (isDevMode) {
mainWindow.webContents.openDevTools();
}

// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
};

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);

// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.
30 changes: 30 additions & 0 deletions angular2/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"compilerOptions": {
"removeComments": false,
"preserveConstEnums": true,
"sourceMap": true,
"declaration": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"strictNullChecks": true,
"experimentalDecorators": true,
"noUnusedLocals": true,
"noImplicitThis": true,
"noUnusedParameters": true,
"importHelpers": true,
"noEmitHelpers": true,
"module": "commonjs",
"moduleResolution": "node",
"pretty": true,
"target": "es2015",
"outDir": "dist"
},
"formatCodeOptions": {
"indentSize": 2,
"tabSize": 2
},
"exclude": [
"node_modules"
]
}
40 changes: 40 additions & 0 deletions angular2/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"rules": {
"curly": true,
"eofline": false,
"align": [true, "parameters"],
"class-name": true,
"indent": [true, "spaces"],
"max-line-length": [true, 150],
"no-consecutive-blank-lines": [true],
"no-trailing-whitespace": true,
"no-duplicate-variable": true,
"no-var-keyword": true,
"no-empty": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-var-requires": true,
"no-require-imports": true,
"one-line": [true,
"check-else",
"check-whitespace",
"check-open-brace"],
"quotemark": [true,
"single",
"avoid-escape"],
"semicolon": [true, "always"],
"typedef-whitespace": [true, {
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}],
"whitespace": [true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"]
}
}

0 comments on commit e80e069

Please sign in to comment.