chore: set up test and build infrastructure
This commit is contained in:
parent
c9c81e1fbc
commit
f57df3cf8a
|
@ -0,0 +1,5 @@
|
||||||
|
node_modules/
|
||||||
|
dist/
|
||||||
|
typings/
|
||||||
|
npm-debug.log
|
||||||
|
.idea/
|
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2016 Google, Inc. http://angular.io
|
||||||
|
|
||||||
|
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.
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*global jasmine, __karma__, window*/
|
||||||
|
Error.stackTraceLimit = Infinity;
|
||||||
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||||
|
|
||||||
|
__karma__.loaded = function () {
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function isJsFile(path) {
|
||||||
|
return path.slice(-3) == '.js';
|
||||||
|
}
|
||||||
|
|
||||||
|
function isSpecFile(path) {
|
||||||
|
return path.slice(-7) == 'spec.js';
|
||||||
|
}
|
||||||
|
|
||||||
|
function isBuiltFile(path) {
|
||||||
|
var builtPath = '/base/dist/';
|
||||||
|
return isJsFile(path) && (path.substr(0, builtPath.length) == builtPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
var allSpecFiles = Object.keys(window.__karma__.files)
|
||||||
|
.filter(isSpecFile)
|
||||||
|
.filter(isBuiltFile);
|
||||||
|
|
||||||
|
// Load our SystemJS configuration.
|
||||||
|
System.config({
|
||||||
|
baseURL: '/base'
|
||||||
|
});
|
||||||
|
|
||||||
|
System.config(
|
||||||
|
{
|
||||||
|
map: {
|
||||||
|
'rxjs': 'node_modules/rxjs',
|
||||||
|
'@angular': 'node_modules/@angular',
|
||||||
|
'app': 'dist'
|
||||||
|
},
|
||||||
|
packages: {
|
||||||
|
'app': {
|
||||||
|
main: 'main.js',
|
||||||
|
defaultExtension: 'js'
|
||||||
|
},
|
||||||
|
'@angular/core': {
|
||||||
|
main: 'index.js',
|
||||||
|
defaultExtension: 'js'
|
||||||
|
},
|
||||||
|
'@angular/compiler': {
|
||||||
|
main: 'index.js',
|
||||||
|
defaultExtension: 'js'
|
||||||
|
},
|
||||||
|
'@angular/common': {
|
||||||
|
main: 'index.js',
|
||||||
|
defaultExtension: 'js'
|
||||||
|
},
|
||||||
|
'@angular/platform-browser': {
|
||||||
|
main: 'index.js',
|
||||||
|
defaultExtension: 'js'
|
||||||
|
},
|
||||||
|
'@angular/platform-browser-dynamic': {
|
||||||
|
main: 'index.js',
|
||||||
|
defaultExtension: 'js'
|
||||||
|
},
|
||||||
|
'rxjs': {
|
||||||
|
main: 'Rx.js',
|
||||||
|
defaultExtension: 'js'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Promise.all([
|
||||||
|
System.import('@angular/core/testing'),
|
||||||
|
System.import('@angular/platform-browser-dynamic/testing')
|
||||||
|
]).then(function (providers) {
|
||||||
|
var testing = providers[0];
|
||||||
|
var testingBrowser = providers[1];
|
||||||
|
|
||||||
|
testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
|
||||||
|
testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
|
||||||
|
|
||||||
|
}).then(function() {
|
||||||
|
// Finally, load all spec files.
|
||||||
|
// This will run the tests directly.
|
||||||
|
return Promise.all(
|
||||||
|
allSpecFiles.map(function (moduleName) {
|
||||||
|
return System.import(moduleName);
|
||||||
|
}));
|
||||||
|
}).then(__karma__.start, __karma__.error);
|
|
@ -0,0 +1,49 @@
|
||||||
|
// Karma configuration
|
||||||
|
module.exports = function(config) {
|
||||||
|
config.set({
|
||||||
|
|
||||||
|
basePath: '',
|
||||||
|
|
||||||
|
frameworks: ['jasmine'],
|
||||||
|
|
||||||
|
files: [
|
||||||
|
// Polyfills.
|
||||||
|
'node_modules/es6-shim/es6-shim.js',
|
||||||
|
|
||||||
|
'node_modules/reflect-metadata/Reflect.js',
|
||||||
|
|
||||||
|
// System.js for module loading
|
||||||
|
'node_modules/systemjs/dist/system-polyfills.js',
|
||||||
|
'node_modules/systemjs/dist/system.src.js',
|
||||||
|
|
||||||
|
// Zone.js dependencies
|
||||||
|
'node_modules/zone.js/dist/zone.js',
|
||||||
|
'node_modules/zone.js/dist/jasmine-patch.js',
|
||||||
|
'node_modules/zone.js/dist/async-test.js',
|
||||||
|
|
||||||
|
// RxJs.
|
||||||
|
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
|
||||||
|
{ pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },
|
||||||
|
|
||||||
|
|
||||||
|
{pattern: 'karma-test-shim.js', included: true, watched: true},
|
||||||
|
{pattern: 'built/test/matchers.js', included: true, watched: true},
|
||||||
|
|
||||||
|
// paths loaded via module imports
|
||||||
|
// Angular itself
|
||||||
|
{pattern: 'node_modules/@angular/**/*.js', included: false, watched: true},
|
||||||
|
{pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: true},
|
||||||
|
|
||||||
|
{pattern: 'dist/**/*.js', included: false, watched: true},
|
||||||
|
{pattern: 'dist/**/*.js.map', included: false, watched: false}
|
||||||
|
],
|
||||||
|
|
||||||
|
reporters: ['mocha'],
|
||||||
|
port: 9876,
|
||||||
|
colors: true,
|
||||||
|
logLevel: config.LOG_INFO,
|
||||||
|
autoWatch: true,
|
||||||
|
browsers: ['Chrome'],
|
||||||
|
singleRun: false
|
||||||
|
})
|
||||||
|
};
|
|
@ -0,0 +1,68 @@
|
||||||
|
{
|
||||||
|
"name": "vladivostok",
|
||||||
|
"version": "0.9.1",
|
||||||
|
"description": "",
|
||||||
|
"main": "./dist/router.js",
|
||||||
|
"jsnext:main": "./dist/es6/router.js",
|
||||||
|
"scripts": {
|
||||||
|
"karma": "karma start",
|
||||||
|
"test": "npm run build; karma start",
|
||||||
|
"build_watch": "rm -rf dist; tsc -w",
|
||||||
|
"build": "rm -rf dist; tsc",
|
||||||
|
"build_npm": "rm -rf dist && tsc -p tsconfig.publish.es5.json && tsc -p tsconfig.publish.es6.json",
|
||||||
|
"postbuild_npm": "cp package.json README.md dist/ && npm run rewrite_npm_package",
|
||||||
|
"rewrite_npm_package": "node --harmony_destructuring tools/rewrite-published-package.js",
|
||||||
|
"build_bundle": "cp -r src router && tsc typings/tsd.d.ts src/router.ts --rootDir . --module system -t es5 --outFile dist/bundles/router.js --moduleResolution node --emitDecoratorMetadata --experimentalDecorators"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"angular2",
|
||||||
|
"angular",
|
||||||
|
"router"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/angular/vladivostok.git"
|
||||||
|
},
|
||||||
|
"author": "vsavkin",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/angular/vladivostok/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/angular/vladivostok#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"@angular/core": "2.0.0-rc.1",
|
||||||
|
"@angular/platform-browser": "2.0.0-rc.1",
|
||||||
|
"@angular/common": "2.0.0-rc.1",
|
||||||
|
"@angular/compiler": "2.0.0-rc.1",
|
||||||
|
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
|
||||||
|
"rxjs": "5.0.0-beta.6"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"es6-module-loader": "^0.17.10",
|
||||||
|
"es6-shim": "^0.35.0",
|
||||||
|
"gulp": "^3.9.0",
|
||||||
|
"gulp-jasmine": "^2.2.1",
|
||||||
|
"gulp-typescript": "^2.10.0",
|
||||||
|
"http-server": "^0.8.5",
|
||||||
|
"jasmine": "^2.4.1",
|
||||||
|
"jasmine-core": "^2.4.1",
|
||||||
|
"json": "^9.0.3",
|
||||||
|
"karma": "^0.13.19",
|
||||||
|
"karma-chrome-launcher": "^0.2.2",
|
||||||
|
"karma-firefox-launcher": "^0.1.7",
|
||||||
|
"karma-jasmine": "^0.3.6",
|
||||||
|
"karma-mocha-reporter": "^2.0.2",
|
||||||
|
"karma-systemjs": "^0.10.0",
|
||||||
|
"parse5": "^1.3.2",
|
||||||
|
"protractor": "3.0.0",
|
||||||
|
"reflect-metadata": "0.1.2",
|
||||||
|
"systemjs": "^0.19.16",
|
||||||
|
"systemjs-builder": "^0.15.7",
|
||||||
|
"traceur": "0.0.96",
|
||||||
|
"tsd": "^0.6.5",
|
||||||
|
"typescript": "1.8.9",
|
||||||
|
"typings": "^0.6.2",
|
||||||
|
"zone.js": "^0.6.6"
|
||||||
|
},
|
||||||
|
"typings": "dist/router.d.ts"
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
export const X = 100;
|
|
@ -0,0 +1,7 @@
|
||||||
|
import {X} from '../src/router';
|
||||||
|
|
||||||
|
describe("Test", () => {
|
||||||
|
it("test", () => {
|
||||||
|
expect(X).toEqual(5);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,17 @@
|
||||||
|
/**
|
||||||
|
* Rewrite the package.json that gets published to npm.
|
||||||
|
* * Change main to point to router.js instead of dist/router.js
|
||||||
|
* * Change angular2 to be a peer dependency
|
||||||
|
*/
|
||||||
|
var fs = require('fs');
|
||||||
|
var srcPackage = require('../package.json');
|
||||||
|
var [MAIN, JSNEXT_MAIN] = ['main', 'jsnext:main'].map(k => srcPackage[k].replace('/dist/', '/'));
|
||||||
|
var outPackage = Object.assign({}, srcPackage, {
|
||||||
|
peerDependencies: srcPackage.dependencies,
|
||||||
|
main: MAIN,
|
||||||
|
typings: "router.d.ts",
|
||||||
|
"jsnext:main": JSNEXT_MAIN,
|
||||||
|
dependencies: undefined
|
||||||
|
});
|
||||||
|
|
||||||
|
fs.writeFileSync('./dist/package.json', JSON.stringify(outPackage, null, 2));
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "es5",
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"outDir": "dist",
|
||||||
|
"rootDir": ".",
|
||||||
|
"sourceMap": true,
|
||||||
|
"sourceRoot": "./",
|
||||||
|
"declaration": true,
|
||||||
|
"removeComments": true
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/router.ts",
|
||||||
|
"test/router.spec.ts",
|
||||||
|
"typings/tsd"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "es5",
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"outDir": "dist",
|
||||||
|
"rootDir": "src",
|
||||||
|
"sourceMap": true,
|
||||||
|
"sourceRoot": "./",
|
||||||
|
"declaration": true,
|
||||||
|
"removeComments": true
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/router.ts",
|
||||||
|
"typings/tsd.d.ts"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"target": "es6",
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"outDir": "dist/es6",
|
||||||
|
"rootDir": "src",
|
||||||
|
"sourceMap": true,
|
||||||
|
"sourceRoot": "./",
|
||||||
|
"declaration": true,
|
||||||
|
"removeComments": true,
|
||||||
|
"moduleResolution": "node"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/router.ts"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"version": "v4",
|
||||||
|
"repo": "borisyankov/DefinitelyTyped",
|
||||||
|
"ref": "master",
|
||||||
|
"path": "typings",
|
||||||
|
"bundle": "typings/tsd.d.ts",
|
||||||
|
"installed": {
|
||||||
|
"jasmine/jasmine.d.ts": {
|
||||||
|
"commit": "e0abafb1a6ff652f7ff967120e312d5c1916eaef"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue