Skip to content

Commit

Permalink
chore(): update to Beta.6, including having our own typings.
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl committed Feb 25, 2016
1 parent a24d5fa commit d93b74e
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# compiled output
/dist
/tmp
/typings

# dependencies
/node_modules
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ node_js:

cache:
directories:
- node_modules
- $HOME/.pub-cache

env:
Expand Down Expand Up @@ -50,6 +49,7 @@ before_install:

install:
- npm install
- npm run typings

before_script:
# Necessary to run test on Travis CI that require a graphical interface.
Expand Down
4 changes: 2 additions & 2 deletions DEV_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
4. Clone your fork.
Recommendation: name your git remotes `upstream` for `angular/material2`
and `<your-username>` for your fork. Also see the [team git shortcuts](https://github.com/angular/material2/wiki/Team-git----bash-shortcuts).
5. From the root of the project, run `npm install`
5. From the root of the project, run `npm install`, then run `npm run typings` to install typescript definitions.


To build the project, run `ng build`.
Expand All @@ -15,7 +15,7 @@ To watch for changes and automatically rebuild, run `ng build --watch`
To bring up a local server, run `ng serve`. This will automatically watch for changes and rebuild.
After the changes rebuild, the browser currently needs to be manually refreshed.

To run unit tests, run `ng test`.
To run unit tests, run `npm test`.

Running e2e tests: <not yet implemented>
Running benchmarks: <not yet implemented>
Expand Down
9 changes: 4 additions & 5 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
var BroccoliSass = require('broccoli-sass');
var broccoliAutoprefixer = require('broccoli-autoprefixer');

const BroccoliTypescript = require('./tools/broccoli/broccoli-typescript').default;
const BroccoliTs2Dart = require('./tools/broccoli/broccoli-ts2dart').default;
const BroccoliDestCopy = require('./tools/broccoli/broccoli-dest-copy').default;
const BroccoliDartFmt = require('./tools/broccoli/broccoli-dartfmt').default;
Expand All @@ -24,6 +25,7 @@ module.exports = function(defaults) {
var demoCssTree = getCssTree('demo-app');
var componentCssTree = getCssTree('components');
var angularAppTree = new Angular2App(defaults);

var dartAppTree = getDartTree('src/');

return mergeTrees([
Expand Down Expand Up @@ -51,6 +53,8 @@ function getDartTree(root) {
generateLibraryName: true,
generateSourceMap: false,
translateBuiltins: true,
typingsRoot: '../../typings/browser/ambient/',
additionalFiles: [path.join(process.cwd(), root, 'typings.d.ts')],
});

const formatter = new BroccoliDartFmt(ts2dart, { dartSDK });
Expand All @@ -65,11 +69,6 @@ function getDartTree(root) {
formatter
]);

//const pubSpecTree = new BroccoliFunnel('.', {
// files: ['pubspec.yaml'],
// //exclude: ['**/*'],
// destDir: 'dart'
//});
const pubSpecTree = new BroccoliFunnel(new BroccoliSource.UnwatchedDir('.'), {
files: ['pubspec.yaml'],
destDir: 'dart',
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,25 @@
"build": "ng build",
"dartanalyzer": "cd dist/dart && pub install && cd ../.. && ts-node scripts/ci/dart_analyzer",
"demo-app": "cd src && ng serve",
"test": "karma start test/karma.conf.js"
"test": "karma start test/karma.conf.js",
"typings": "typings install --ambient"
},
"version": "2.0.0-alpha.0",
"license": "MIT",
"engines": {
"node": ">= 4.2.1 < 5"
},
"dependencies": {
"angular2": "2.0.0-beta.0",
"angular2": "2.0.0-beta.6",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"systemjs": "0.19.4",
"zone.js": "0.5.10"
"zone.js": "0.5.14"
},
"devDependencies": {
"angular-cli": "0.0.*",
"angular-cli": "^0.0.24",
"angular-cli-github-pages": "^0.2.0",
"broccoli-autoprefixer": "^4.1.0",
"broccoli-funnel": "^1.0.1",
Expand All @@ -51,9 +52,10 @@
"strip-ansi": "^3.0.0",
"symlink-or-copy": "^1.0.1",
"ts-node": "^0.5.5",
"ts2dart": "^0.7.25",
"ts2dart": "^0.7.27",
"tslint": "^3.2.2",
"typescript": "^1.7.5",
"typings": "^0.6.8",
"which": "^1.2.4"
}
}
1 change: 1 addition & 0 deletions scripts/ci/build-and-test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -e

echo "======= Starting build-and-test.sh ========================================"

Expand Down
4 changes: 3 additions & 1 deletion src/components/sidenav/sidenav.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export function main() {
.then((_: any) => { done(); });
}, 8000);

it('open() twice returns the same promise', (done: any) => {
it('open/close() twice returns the same promise', (done: any) => {
let fixture: ComponentFixture;
let sidenav: MdSidenav;

Expand All @@ -169,12 +169,14 @@ export function main() {

promise = sidenav.open();
expect(sidenav.open()).toBe(promise);
return wait(1);
})
.then((_: any) => { return wait(1); })
.then((_: any) => {
fixture.detectChanges();
return promise;
})
.then((_: any) => { return wait(1); })
.then((_: any) => {
promise = sidenav.close();
expect(sidenav.close()).toBe(promise);
Expand Down
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<demo-app>Loading...</demo-app>

<script src="vendor/systemjs/dist/system.src.js"></script>
<script src="vendor/systemjs/dist/system-polyfills.src.js"></script>
<script src="vendor/systemjs/dist/system-polyfills.js"></script>
<script src="vendor/rxjs/bundles/Rx.js"></script>
<script src="vendor/angular2/bundles/angular2.dev.js"></script>
<script src="vendor/angular2/bundles/http.dev.js"></script>
Expand Down
1 change: 1 addition & 0 deletions src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference path="../typings/browser.d.ts" />
30 changes: 26 additions & 4 deletions test/karma-test-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,32 @@ System.config({
}
});

System.import('angular2/platform/browser').then(function(browser_adapter) {
// TODO: once beta is out we should change this code to use a "test platform"
browser_adapter.BrowserDomAdapter.makeCurrent();
}).then(function() {

/**
* Bootstrap the browser testing providers from Angular2. The equivalent code in TypeScript
* would be:
*
* <code>
* import {setBaseTestProviders} from 'angular2/testing';
* import * as browser from 'angular2/platform/testing/browser';
*
* setBaseTestProviders(browser.TEST_BROWSER_PLATFORM_PROVIDERS,
* browser.TEST_BROWSER_APPLICATION_PROVIDERS);
* </code>
*
* See https://github.com/angular/angular/blob/master/CHANGELOG.md#200-beta2-2016-01-28
*
* Followed by the normal import of all spec files, then bootstrap Karma.
*/
Promise.all([
System.import('angular2/testing'),
System.import('angular2/platform/testing/browser'),
]).then(function(imports) {
var testing = imports[0];
var browser = imports[1];
testing.setBaseTestProviders(browser.TEST_BROWSER_PLATFORM_PROVIDERS,
browser.TEST_BROWSER_APPLICATION_PROVIDERS);

return Promise.all(
Object.keys(window.__karma__.files)
.filter(isSpecFile)
Expand Down
14 changes: 9 additions & 5 deletions test/karma.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ export function config(config) {
require('karma-firefox-launcher'),
],
files: [
{pattern: 'node_modules/es6-shim/es6-shim.js', included: true, watched: true},
{pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true,
watched: true},
{pattern: 'node_modules/es6-shim/es6-shim.min.js', included: true, watched: true},
{pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: true, watched: true},
'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',

{pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: true},
{pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true},
{pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: true},
{pattern: 'node_modules/angular2/bundles/angular2.js', included: true, watched: true},
'node_modules/reflect-metadata/Reflect.js',
{pattern: 'node_modules/angular2/bundles/angular2.dev.js', included: true, watched: true},
{pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: true},

{pattern: 'test/karma-test-shim.js', included: true, watched: true},
Expand Down Expand Up @@ -78,9 +80,11 @@ export function config(config) {
startTunnel: false,
retryLimit: 1,
timeout: 600,
pollingTimeout: 10000
pollingTimeout: 20000
},

browserDisconnectTimeout: 20000,
browserNoActivityTimeout: 100000,
browsers: ['Chrome'],

singleRun: false
Expand Down
34 changes: 22 additions & 12 deletions tools/broccoli/broccoli-ts2dart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,44 @@
import fs = require('fs');
import fse = require('fs-extra');
import path = require('path');
import * as ts2dart from 'ts2dart';
import {wrapDiffingPlugin, DiffingBroccoliPlugin, DiffResult} from './diffing-broccoli-plugin';

class TSToDartTranspiler implements DiffingBroccoliPlugin {
static includeExtensions = ['.ts'];

private transpiler: ts2dart.Transpiler;
private transpiler: any /*ts2dart.Transpiler*/;
private additionalFiles: string[];

constructor(public inputPath: string, public cachePath: string,
public options: ts2dart.TranspilerOptions) {
public options: any /*ts2dart.TranspilerOptions*/) {
// Additional files to include in the transpile call. These files could include, e.g.,
// .d.ts files. They will always be included in the transpile call below, even if they
// weren't modified.
this.additionalFiles = options.additionalFiles || [];
// Delete additionalFiles as the transpiler does not support that option.
delete options.additionalFiles;

options.basePath = inputPath;
// Workaround for https://github.com/dart-lang/dart_style/issues/493
var ts2dart = require('ts2dart');
this.transpiler = new ts2dart.Transpiler(options);
}

rebuild(treeDiff: DiffResult) {
let toEmit = [path.resolve(this.inputPath, 'angular2/manual_typings/globals.d.ts')];
let getDartFilePath = (path: string) => path.replace(/((\.js)|(\.ts))$/i, '.dart');
treeDiff.addedPaths.concat(treeDiff.changedPaths)
.forEach((changedPath) => {
let inputFilePath = path.resolve(this.inputPath, changedPath);
.filter(name => !name.match(/\.d\.ts$/))
.forEach((changedPath) => {
let inputFilePath = path.resolve(this.inputPath, changedPath);

// Ignore files which don't need to be transpiled to Dart
let dartInputFilePath = getDartFilePath(inputFilePath);
if (fs.existsSync(dartInputFilePath)) return;
// Ignore files which don't need to be transpiled to Dart
let dartInputFilePath = getDartFilePath(inputFilePath);
if (fs.existsSync(dartInputFilePath)) return;

// Prepare to rebuild
toEmit.push(path.resolve(this.inputPath, changedPath));
});
// Prepare to rebuild
toEmit.push(path.resolve(this.inputPath, changedPath));
});

treeDiff.removedPaths.forEach((removedPath) => {
let absolutePath = path.resolve(this.inputPath, removedPath);
Expand All @@ -43,7 +53,7 @@ class TSToDartTranspiler implements DiffingBroccoliPlugin {
let dartOutputFilePath = getDartFilePath(removedPath);
fs.unlinkSync(path.join(this.cachePath, dartOutputFilePath));
});
this.transpiler.transpile(toEmit, this.cachePath);
this.transpiler.transpile(this.additionalFiles.concat(toEmit), this.cachePath);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tools/build/dart_analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function analyze(dir: string, command: string, use_ddc: boolean = false):

function analyze_(command, dirName, done, useDdc) {
// TODO remove --package-warnings once dartanalyzer handles transitive libraries
var flags = ['--fatal-warnings', '--package-warnings', '--format=machine'];
var flags = ['--fatal-warnings', '--format=machine'];

if (useDdc) {
console.log('Using DDC analyzer to analyze', dirName);
Expand Down
11 changes: 11 additions & 0 deletions typings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "material2",
"dependencies": {},
"devDependencies": {},
"ambientDevDependencies": {
"jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#26c98c8a9530c44f8c801ccc3b2057e2101187ee"
},
"ambientDependencies": {
"es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2"
}
}

0 comments on commit d93b74e

Please sign in to comment.