Angula 4 based Spring-Flo missing files

This commit is contained in:
BoykoAlex
2017-08-22 11:49:47 -04:00
parent 7ad4d7afd6
commit 9c584e7ad3
102 changed files with 7282 additions and 0 deletions

10
integration/.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
node_modules
npm-debug.log
src/**/*.js
!src/systemjs.config.js
!src/systemjs-angular-loader.js
*.js.map
e2e/**/*.js
e2e/**/*.js.map
out-tsc/*
dist/*

26
integration/README.md Normal file
View File

@@ -0,0 +1,26 @@
# Integration App
This is a simplified version of https://github.com/angular/quickstart used to test the built lib.
## npm scripts
We've captured many of the most useful commands in npm scripts defined in the `package.json`:
* `npm start` - runs the compiler and a server at the same time, both in "watch mode".
* `npm run e2e` - compiles the app and run e2e tests.
* `npm run e2e:aot` - compiles and the app with AOT and run e2e tests.
If you need to manually test a library build, follow these steps:
```
# starting at the project root, build the library
npm run build
# clean the integration app
npm run preintegration
cd integration
npm install
```
Now the library is installed in your integration app.
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.

View File

@@ -0,0 +1,5 @@
{
"server": {
"baseDir": "dist"
}
}

View File

@@ -0,0 +1,11 @@
{
"open": false,
"logLevel": "silent",
"port": 8080,
"server": {
"baseDir": "dist",
"middleware": {
"0": null
}
}
}

View File

@@ -0,0 +1,14 @@
{
"open": false,
"logLevel": "silent",
"port": 8080,
"server": {
"baseDir": "src",
"routes": {
"/node_modules": "node_modules"
},
"middleware": {
"0": null
}
}
}

View File

@@ -0,0 +1,8 @@
{
"server": {
"baseDir": "src",
"routes": {
"/node_modules": "node_modules"
}
}
}

93
integration/build.js Normal file
View File

@@ -0,0 +1,93 @@
const fs = require('fs');
const path = require('path');
const glob = require('glob');
const rollup = require('rollup');
const uglify = require('rollup-plugin-uglify');
const commonjs = require('rollup-plugin-commonjs');
const nodeResolve = require('rollup-plugin-node-resolve');
const ngc = require('@angular/compiler-cli/src/main').main;
const srcDir = path.join(__dirname, 'src/');
const distDir = path.join(__dirname, 'dist/');
const aotDir = path.join(__dirname, 'aot/');
const rollupConfig = {
entry: `${srcDir}/main-aot.js`,
sourceMap: false,
format: 'iife',
onwarn: function (warning) {
// Skip certain warnings
if (warning.code === 'THIS_IS_UNDEFINED') { return; }
// console.warn everything else
console.warn(warning.message);
},
plugins: [
nodeResolve({ jsnext: true, module: true }),
commonjs({
include: ['node_modules/rxjs/**']
}),
uglify()
]
};
return Promise.resolve()
// Compile using ngc.
.then(() => ngc({ project: `./tsconfig.aot.json` }))
// Create dist dir.
.then(() => _recursiveMkDir(distDir))
// Copy files.
.then(() => {
// Copy and rename index-aot.html.
fs.createReadStream(path.join(srcDir, 'index-aot.html'))
.pipe(fs.createWriteStream(path.join(distDir, 'index.html')));
// Copy global stylesheets, images, etc.
const assets = [
'favicon.ico',
'styles.css'
];
return Promise.all(assets.map(asset => _relativeCopy(asset, srcDir, distDir)));
})
// Bundle app.
.then(() => rollup.rollup(rollupConfig))
// Concatenate app and scripts.
.then(bundle => {
const appBundle = bundle.generate(rollupConfig);
const scripts = [
'node_modules/core-js/client/shim.min.js',
'node_modules/zone.js/dist/zone.min.js'
];
let concatenatedScripts = scripts.map((script) => {
return fs.readFileSync(path.join(__dirname, script)).toString();
}).join('\n;');
concatenatedScripts = concatenatedScripts.concat('\n;', appBundle.code);
fs.writeFileSync(path.join(distDir, 'bundle.js'), concatenatedScripts);
});
// Copy files maintaining relative paths.
function _relativeCopy(fileGlob, from, to) {
return glob(fileGlob, { cwd: from, nodir: true }, (err, files) => {
if (err) throw err;
files.forEach(file => {
const origin = path.join(from, file);
const dest = path.join(to, file);
_recursiveMkDir(path.dirname(dest));
fs.createReadStream(origin).pipe(fs.createWriteStream(dest));
})
})
}
// Recursively create a dir.
function _recursiveMkDir(dir) {
if (!fs.existsSync(dir)) {
_recursiveMkDir(path.dirname(dir));
fs.mkdirSync(dir);
}
}

0
integration/e2e/app.e2e-spec.d.ts vendored Normal file
View File

View File

@@ -0,0 +1,21 @@
import { browser, element, by } from 'protractor';
describe('QuickStart Lib E2E Tests', function () {
beforeEach(() => browser.get(''));
afterEach(() => {
browser.manage().logs().get('browser').then((browserLog: any[]) => {
expect(browserLog).toEqual([]);
});
});
it('should display lib', () => {
expect(element(by.css('h2')).getText()).toEqual('Hello Angular Library');
});
it('should display meaning', () => {
expect(element(by.css('h3')).getText()).toEqual('Meaning is: 42');
});
});

View File

@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}

55
integration/package.json Normal file
View File

@@ -0,0 +1,55 @@
{
"name": "integration-test",
"version": "1.0.0",
"description": "App for integration tests",
"scripts": {
"clean": "rimraf aot/ dist/ node_modules/spring-flo/",
"build": "tsc -p src/",
"build:watch": "tsc -p src/ -w",
"build:e2e": "tsc -p e2e/",
"build:aot": "node build.js",
"serve": "lite-server -c=bs-config.json",
"serve:aot": "lite-server -c bs-config.aot.json",
"serve:e2e": "lite-server -c=bs-config.e2e.json",
"serve:e2e-aot": "lite-server -c bs-config.e2e-aot.json",
"prestart": "npm run build",
"start": "concurrently \"npm run build:watch\" \"npm run serve\"",
"pree2e": "npm run build:e2e && npm run build",
"e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
"pree2e:aot": "npm run build:e2e && npm run build:aot",
"e2e:aot": "concurrently \"npm run serve:e2e-aot\" \"npm run protractor\" --kill-others --success first",
"preprotractor": "webdriver-manager update",
"protractor": "protractor protractor.config.js"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@angular/common": "^4.1.3",
"@angular/compiler": "^4.1.3",
"@angular/compiler-cli": "^4.1.3",
"@angular/core": "^4.1.3",
"@angular/platform-browser": "^4.1.3",
"@angular/platform-browser-dynamic": "^4.1.3",
"spring-flo": "../dist/",
"core-js": "^2.4.1",
"rxjs": "5.0.1",
"systemjs": "0.19.40",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@types/jasmine": "2.5.36",
"concurrently": "^3.4.0",
"jasmine-core": "~2.4.1",
"glob": "^7.1.1",
"lite-server": "^2.2.2",
"protractor": "~5.1.0",
"rimraf": "^2.5.4",
"rollup": "^0.42.0",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-resolve": "3.0.0",
"rollup-plugin-uglify": "^2.0.1",
"typescript": "~2.3.0"
},
"repository": {}
}

View File

@@ -0,0 +1,12 @@
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.js'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:8080/',
framework: 'jasmine'
};

View File

@@ -0,0 +1,5 @@
import { LibService } from 'spring-flo';
export declare class AppComponent {
meaning: number;
constructor(libService: LibService);
}

View File

@@ -0,0 +1,2 @@
<my-lib></my-lib>
<h3>Meaning is: {{meaning}}</h3>

View File

@@ -0,0 +1,13 @@
import { Component } from '@angular/core';
import { LibService } from 'spring-flo';
@Component({
selector: 'integration-app',
templateUrl: './app.component.html',
})
export class AppComponent {
meaning: number;
constructor(libService: LibService) {
this.meaning = libService.getMeaning();
}
}

2
integration/src/app/app.module.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare class AppModule {
}

View File

@@ -0,0 +1,12 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { LibModule } from 'spring-flo';
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule, LibModule],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }

BIN
integration/src/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>Angular QuickStart</title>
<base href="/">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<!-- Workaround for module.id -->
<script>window.module = 'aot';</script>
</head>
<body>
<integration-app>Loading...</integration-app>
</body>
<script src="bundle.js"></script>
</html>

View File

@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<title>Angular QuickStart</title>
<base href="/">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('main.js').catch(function(err){ console.error(err); });
</script>
</head>
<body>
<integration-app>Loading AppComponent content here ...</integration-app>
</body>
</html>

0
integration/src/main-aot.d.ts vendored Normal file
View File

View File

@@ -0,0 +1,5 @@
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModuleNgFactory } from '../out-tsc/src/app/app.module.ngfactory';
platformBrowserDynamic().bootstrapModuleFactory(AppModuleNgFactory);

0
integration/src/main.d.ts vendored Normal file
View File

5
integration/src/main.ts Normal file
View File

@@ -0,0 +1,5 @@
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule);

View File

@@ -0,0 +1,5 @@
h1 {
color: #369;
font-family: Arial, Helvetica, sans-serif;
font-size: 250%;
}

View File

@@ -0,0 +1,49 @@
var templateUrlRegex = /templateUrl\s*:(\s*['"`](.*?)['"`]\s*)/gm;
var stylesRegex = /styleUrls *:(\s*\[[^\]]*?\])/g;
var stringRegex = /(['`"])((?:[^\\]\\\1|.)*?)\1/g;
module.exports.translate = function (load) {
if (load.source.indexOf('moduleId') != -1) return load;
var url = document.createElement('a');
url.href = load.address;
var basePathParts = url.pathname.split('/');
basePathParts.pop();
var basePath = basePathParts.join('/');
var baseHref = document.createElement('a');
baseHref.href = this.baseURL;
baseHref = baseHref.pathname;
if (!baseHref.startsWith('/base/')) { // it is not karma
basePath = basePath.replace(baseHref, '');
}
load.source = load.source
.replace(templateUrlRegex, function (match, quote, url) {
let resolvedUrl = url;
if (url.startsWith('.')) {
resolvedUrl = basePath + url.substr(1);
}
return 'templateUrl: "' + resolvedUrl + '"';
})
.replace(stylesRegex, function (match, relativeUrls) {
var urls = [];
while ((match = stringRegex.exec(relativeUrls)) !== null) {
if (match[2].startsWith('.')) {
urls.push('"' + basePath + match[2].substr(1) + '"');
} else {
urls.push('"' + match[2] + '"');
}
}
return "styleUrls: [" + urls.join(', ') + "]";
});
return load;
};

View File

@@ -0,0 +1,46 @@
/**
* System configuration for Angular samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'spring-flo': 'npm:spring-flo/bundles/spring-flo.umd.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
defaultExtension: 'js',
meta: {
'./*.js': {
loader: 'systemjs-angular-loader.js'
}
}
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);

View File

@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
"exclude": [
"main-aot.ts"
]
}

View File

@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2015",
"dom"
],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
"files": [
"src/app/app.module.ts",
"src/main-aot.ts"
],
"angularCompilerOptions": {
"genDir": "out-tsc",
"skipMetadataEmit": true
}
}