Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 14bb183

Browse files
committed
add example
1 parent bf8c09f commit 14bb183

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+673
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
dist/
2+
node_modules/
3+
out-tsc/
4+
debug.log
5+
npm-debug.log
6+
src/**/*.js
7+
!src/demo/systemjs.config.js
8+
!src/demo/systemjs.config.lib.js
9+
*.js.map
10+
e2e/**/*.js
11+
e2e/**/*.js.map
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Ignore eveything by default.
2+
/*
3+
4+
# Only publish these files/folders:
5+
!dist/
6+
!LICENSE
7+
!package.json
8+
!README.md
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2014-2016 Google, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Angular QuickStart Lib
2+
[![Build Status][travis-badge]][travis-badge-url]
3+
4+
This is a simple library quickstart for Angular libraries.
5+
6+
Features:
7+
- a simple a library
8+
- unit tests for the library
9+
- a demo application that consumes the library in JIT mode and runs in watch mode
10+
- an integration app that consumes the library in JIT and AOT mode and runs e2e tests
11+
12+
Common tasks are present as npm scripts:
13+
14+
- `npm start` to run a live-reload server with the demo app
15+
- `npm run test` to test in watch mode, or `npm run test:once` to only run once
16+
- `npm run build` to build the library
17+
- `npm run lint` to lint
18+
- `npm run clean` to clean
19+
- `npm run integration` to run the integration e2e tests
20+
- `npm install ./relative/path/to/lib` after `npm run build` to test locally in another app
21+
22+
If you need to debug the integration app, please check `./integration/README.md`.
23+
24+
[travis-badge]: https://travis-ci.org/filipesilva/angular-quickstart-lib.svg?branch=master
25+
[travis-badge-url]: https://travis-ci.org/filipesilva/angular-quickstart-lib
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
npm-debug.log
3+
src/**/*.js
4+
!src/systemjs.config.js
5+
*.js.map
6+
e2e/**/*.js
7+
e2e/**/*.js.map
8+
out-tsc/*
9+
dist/*
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Integration App
2+
3+
This is a simplified version of https://github.com/angular/quickstart used to test the built lib.
4+
5+
## npm scripts
6+
7+
We've captured many of the most useful commands in npm scripts defined in the `package.json`:
8+
9+
* `npm start` - runs the compiler and a server at the same time, both in "watch mode".
10+
* `npm run e2e` - compiles the app and run e2e tests.
11+
* `npm run e2e:aot` - compiles and the app with AOT and run e2e tests.
12+
13+
14+
If you need to manually test a library build, follow these steps:
15+
```
16+
# starting at the project root, build the library
17+
npm run build
18+
# clean the integration app
19+
npm run preintegration
20+
cd integration
21+
npm install
22+
```
23+
24+
Now the library is installed in your integration app.
25+
26+
You can use `npm start` to start a live reload server running the app in JIT mode, or `npm run build && npm run serve:aot` to run a static server in AOT mode.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"server": {
3+
"baseDir": "dist"
4+
}
5+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"open": false,
3+
"logLevel": "silent",
4+
"port": 8080,
5+
"server": {
6+
"baseDir": "dist",
7+
"middleware": {
8+
"0": null
9+
}
10+
}
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"open": false,
3+
"logLevel": "silent",
4+
"port": 8080,
5+
"server": {
6+
"baseDir": "src",
7+
"routes": {
8+
"/node_modules": "node_modules"
9+
},
10+
"middleware": {
11+
"0": null
12+
}
13+
}
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"server": {
3+
"baseDir": "src",
4+
"routes": {
5+
"/node_modules": "node_modules"
6+
}
7+
}
8+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { browser, element, by } from 'protractor';
2+
3+
describe('QuickStart Lib E2E Tests', function () {
4+
5+
beforeEach(() => browser.get(''));
6+
7+
afterEach(() => {
8+
browser.manage().logs().get('browser').then((browserLog: any[]) => {
9+
expect(browserLog).toEqual([]);
10+
});
11+
});
12+
13+
it('should display lib', () => {
14+
expect(element(by.css('h2')).getText()).toEqual('Hello Angular Library');
15+
});
16+
17+
it('should display meaning', () => {
18+
expect(element(by.css('h3')).getText()).toEqual('Meaning is: 42');
19+
});
20+
21+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"moduleResolution": "node",
6+
"sourceMap": true,
7+
"emitDecoratorMetadata": true,
8+
"experimentalDecorators": true,
9+
"lib": [ "es2015", "dom" ],
10+
"noImplicitAny": true,
11+
"suppressImplicitAnyIndexErrors": true
12+
}
13+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "integration-test",
3+
"version": "1.0.0",
4+
"description": "App for integration tests",
5+
"scripts": {
6+
"clean": "rimraf aot/ dist/ node_modules/angular-quickstart-lib/",
7+
"build": "tsc -p src/",
8+
"build:watch": "tsc -p src/ -w",
9+
"build:e2e": "tsc -p e2e/",
10+
"build:aot": "node build.js",
11+
"serve": "lite-server -c=bs-config.json",
12+
"serve:aot": "lite-server -c bs-config.aot.json",
13+
"serve:e2e": "lite-server -c=bs-config.e2e.json",
14+
"serve:e2e-aot": "lite-server -c bs-config.e2e-aot.json",
15+
"prestart": "npm run build",
16+
"start": "concurrently \"npm run build:watch\" \"npm run serve\"",
17+
"pree2e": "npm run build:e2e && npm run build",
18+
"e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
19+
"pree2e:aot": "npm run build:e2e && npm run build:aot",
20+
"e2e:aot": "concurrently \"npm run serve:e2e-aot\" \"npm run protractor\" --kill-others --success first",
21+
"preprotractor": "webdriver-manager update",
22+
"protractor": "protractor protractor.config.js"
23+
},
24+
"keywords": [],
25+
"author": "",
26+
"license": "MIT",
27+
"dependencies": {
28+
"@angular/common": "^4.0.0-rc.3",
29+
"@angular/compiler": "^4.0.0-rc.3",
30+
"@angular/compiler-cli": "^4.0.0-rc.3",
31+
"@angular/core": "^4.0.0-rc.3",
32+
"@angular/platform-browser": "^4.0.0-rc.3",
33+
"@angular/platform-browser-dynamic": "^4.0.0-rc.3",
34+
"angular-quickstart-lib": "../",
35+
"core-js": "^2.4.1",
36+
"rxjs": "5.0.1",
37+
"systemjs": "0.19.40",
38+
"zone.js": "^0.8.4"
39+
},
40+
"devDependencies": {
41+
"@types/jasmine": "2.5.36",
42+
"concurrently": "^3.2.0",
43+
"jasmine-core": "~2.4.1",
44+
"glob": "^7.1.1",
45+
"lite-server": "^2.2.2",
46+
"protractor": "~5.1.0",
47+
"rimraf": "^2.5.4",
48+
"rollup": "^0.41.4",
49+
"rollup-plugin-commonjs": "^7.0.0",
50+
"rollup-plugin-node-resolve": "^2.0.0",
51+
"rollup-plugin-uglify": "^1.0.1",
52+
"typescript": "^2.0.10"
53+
},
54+
"repository": {}
55+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Component } from '@angular/core';
2+
import { LibService } from 'angular-quickstart-lib';
3+
4+
@Component({
5+
selector: 'integration-app',
6+
template: `
7+
<my-lib></my-lib>
8+
<h3>Meaning is: {{meaning}}</h3>
9+
`,
10+
})
11+
export class AppComponent {
12+
meaning: number;
13+
constructor(libService: LibService) {
14+
this.meaning = libService.getMeaning();
15+
}
16+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { NgModule } from '@angular/core';
2+
import { BrowserModule } from '@angular/platform-browser';
3+
import { LibModule } from 'angular-quickstart-lib';
4+
5+
import { AppComponent } from './app.component';
6+
7+
@NgModule({
8+
imports: [ BrowserModule, LibModule],
9+
declarations: [ AppComponent ],
10+
bootstrap: [ AppComponent ]
11+
})
12+
export class AppModule { }
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Angular QuickStart</title>
5+
<base href="/">
6+
<meta charset="UTF-8">
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<link rel="stylesheet" href="styles.css">
9+
10+
<!-- Workaround for module.id -->
11+
<script>window.module = 'aot';</script>
12+
</head>
13+
14+
<body>
15+
<integration-app>Loading...</integration-app>
16+
</body>
17+
<script src="bundle.js"></script>
18+
</html>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Angular QuickStart</title>
5+
<base href="/">
6+
<meta charset="UTF-8">
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<link rel="stylesheet" href="styles.css">
9+
10+
<!-- Polyfill(s) for older browsers -->
11+
<script src="node_modules/core-js/client/shim.min.js"></script>
12+
13+
<script src="node_modules/zone.js/dist/zone.js"></script>
14+
<script src="node_modules/systemjs/dist/system.src.js"></script>
15+
16+
<script src="systemjs.config.js"></script>
17+
<script>
18+
System.import('main.js').catch(function(err){ console.error(err); });
19+
</script>
20+
</head>
21+
22+
<body>
23+
<integration-app>Loading AppComponent content here ...</integration-app>
24+
</body>
25+
</html>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
2+
3+
import { AppModuleNgFactory } from '../out-tsc/src/app/app.module.ngfactory';
4+
5+
platformBrowserDynamic().bootstrapModuleFactory(AppModuleNgFactory);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
2+
3+
import { AppModule } from './app/app.module';
4+
5+
platformBrowserDynamic().bootstrapModule(AppModule);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
h1 {
2+
color: #369;
3+
font-family: Arial, Helvetica, sans-serif;
4+
font-size: 250%;
5+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* System configuration for Angular samples
3+
* Adjust as necessary for your application needs.
4+
*/
5+
(function (global) {
6+
System.config({
7+
paths: {
8+
// paths serve as alias
9+
'npm:': 'node_modules/'
10+
},
11+
// map tells the System loader where to look for things
12+
map: {
13+
// our app is within the app folder
14+
app: 'app',
15+
16+
// angular bundles
17+
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
18+
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
19+
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
20+
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
21+
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
22+
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
23+
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
24+
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
25+
26+
// other libraries
27+
'rxjs': 'npm:rxjs',
28+
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
29+
'angular-quickstart-lib': 'npm:angular-quickstart-lib/dist/angular-quickstart-lib.umd.js'
30+
},
31+
// packages tells the System loader how to load when no filename and/or no extension
32+
packages: {
33+
app: {
34+
defaultExtension: 'js'
35+
},
36+
rxjs: {
37+
defaultExtension: 'js'
38+
}
39+
}
40+
});
41+
})(this);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"moduleResolution": "node",
6+
"sourceMap": true,
7+
"emitDecoratorMetadata": true,
8+
"experimentalDecorators": true,
9+
"lib": [ "es2015", "dom" ],
10+
"noImplicitAny": true,
11+
"suppressImplicitAnyIndexErrors": true
12+
},
13+
"exclude": [
14+
"main-aot.ts"
15+
]
16+
}

0 commit comments

Comments
 (0)