Skip to content

Commit

Permalink
a handful of package and publish chores (#312)
Browse files Browse the repository at this point in the history
* chore(publish): make npm publish only run if build succeeded

* chore(package): support many versions of Angular RC

Fixes #272

* chore(package): make firebase a dependency instead of peerDep in published package

Fixes #311

* chore(package): write es modules to esm instead of es6 directory

BREAKING CHANGE:

Previously, es modules were published to the es6/ directory inside the npm
package. This change publishes them to the esm directory to be consistent
with other angular packages. Currently, the es6 directory is still published
in the npm package, but will be removed in a future release.

Fixes #310

* test: remove deprecated @angular/core/testing imports

* fix: inline sources in source maps included with npm distribution

Fixes #293

* docs(setup): add note about installing promise typings to guides

Closes #246
  • Loading branch information
jeffbcross authored and davideast committed Jul 1, 2016
1 parent 1a1ceb9 commit ac8c6be
Show file tree
Hide file tree
Showing 16 changed files with 195 additions and 195 deletions.
18 changes: 18 additions & 0 deletions docs/1-install-and-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ In your `tsconfig.json` file include the following line in your `"files"` array:

This is a temporary step until the Firebase typings are published to npm.

Unless you're targeting ES6 output in tsconfig.json, you'll also need to install
typings for the global Promise constructor. Run this command:

`$ typings install --save --global es6-promise`

If you're using Angular CLI, the typings will automatically be added to your
tsconfig since there is already a reference to `"typings.d.ts"` which transitively
includes `es6-promise`. If you're using a different seed project, or managing your
build yourself, just add the reference to your tsconfig files array:

```json
"files": [
"node_modules/angularfire2/firebase3.d.ts",
"typings/main.d.ts"
]
```


### 4. Include AngularFire 2 and Firebase in the vendor files

Open `angular-cli-build.js`.
Expand Down
3 changes: 1 addition & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ module.exports = function(config) {

{pattern: 'node_modules/firebase/firebase.js', included: false, watched: false},
{pattern: 'dist/**/*.js', included: false, watched: true},
{pattern: 'dist/**/*.js.map', included: false, watched: false},
{pattern: 'src/**/*.ts', included: false, watched: false}
{pattern: 'dist/**/*.js.map', included: false, watched: false}
],

port: 9876,
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"version": "2.0.0-beta.2",
"description": "",
"main": "./dist/angularfire2.js",
"jsnext:main": "./dist/es6/angularfire2.js",
"jsnext:main": "./dist/esm/angularfire2.js",
"scripts": {
"test": "npm run build; karma start",
"docs": "typedoc --out docs/api/ --module commonjs --mode modules --name AngularFire2 src",
"build": "rm -rf dist; tsc",
"build_npm": "rm -rf dist && tsc -p tsconfig.publish.es5.json && tsc -p tsconfig.publish.es6.json",
"build_npm": "rm -rf dist && tsc -p tsconfig.publish.es5.json && tsc -p tsconfig.publish.es6.json && tsc -p tsconfig.publish.es6-deprecated.json",
"postbuild_npm": "cp manual_typings/firebase3/firebase3.d.ts package.json README.md .npmignore dist/ && npm run rewrite_npm_package",
"rewrite_npm_package": "node --harmony_destructuring tools/rewrite-published-package.js",
"build_bundle": "cp -r src angularfire2 && tsc typings/main.d.ts angularfire2.ts --rootDir . --module system -t es5 --outFile dist/bundles/angularfire2.js --moduleResolution node --emitDecoratorMetadata --experimentalDecorators",
Expand All @@ -32,11 +32,11 @@
},
"homepage": "https://github.com/angular/angularfire2#readme",
"dependencies": {
"@angular/core": "2.0.0-rc.2",
"@angular/platform-browser": "2.0.0-rc.2",
"@angular/common": "2.0.0-rc.2",
"@angular/compiler": "2.0.0-rc.2",
"@angular/platform-browser-dynamic": "2.0.0-rc.2",
"@angular/core": "2.0.0-rc.2 || 2.0.0-rc.3 || 2.0.0-rc.4 || 2.0.0-rc.5 || 2.0.0-rc.6 || 2.0.0-rc.7 || 2.0.0-rc.8 || 2.0.0-rc.9",
"@angular/platform-browser": "2.0.0-rc.2 || 2.0.0-rc.3 || 2.0.0-rc.4 || 2.0.0-rc.5 || 2.0.0-rc.6 || 2.0.0-rc.7 || 2.0.0-rc.8 || 2.0.0-rc.9",
"@angular/common": "2.0.0-rc.2 || 2.0.0-rc.3 || 2.0.0-rc.4 || 2.0.0-rc.5 || 2.0.0-rc.6 || 2.0.0-rc.7 || 2.0.0-rc.8 || 2.0.0-rc.9",
"@angular/compiler": "2.0.0-rc.2 || 2.0.0-rc.3 || 2.0.0-rc.4 || 2.0.0-rc.5 || 2.0.0-rc.6 || 2.0.0-rc.7 || 2.0.0-rc.8 || 2.0.0-rc.9",
"@angular/platform-browser-dynamic": "2.0.0-rc.2 || 2.0.0-rc.3 || 2.0.0-rc.4 || 2.0.0-rc.5 || 2.0.0-rc.6 || 2.0.0-rc.7 || 2.0.0-rc.8 || 2.0.0-rc.9",
"firebase": "^3.0.3",
"rxjs": "5.0.0-beta.6"
},
Expand Down
3 changes: 1 addition & 2 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
npm run build_npm
npm publish dist
npm run build_npm && npm publish dist
42 changes: 16 additions & 26 deletions src/angularfire2.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import {
describe,
ddescribe,
it,
iit,
beforeEach,
beforeEachProviders,
expect,
inject,
injectAsync,
async
addProviders,
inject
} from '@angular/core/testing';
import {ReflectiveInjector, provide, Provider} from '@angular/core';
import {
Expand Down Expand Up @@ -43,18 +35,16 @@ describe('angularfire', () => {
var listOfQuestionsRef: firebase.database.Reference;
var angularFire2: AngularFire;

beforeEachProviders(() => [FIREBASE_PROVIDERS, defaultFirebase(firebaseConfig)]);

describe('things', () => {

})
beforeEach(inject([FirebaseApp, AngularFire], (firebaseApp: firebase.app.App, _af: AngularFire) => {
angularFire2 = _af;
app = firebaseApp;
rootRef = app.database().ref();
questionsRef = rootRef.child('questions');
listOfQuestionsRef = rootRef.child('list-of-questions');
}));
beforeEach(() => {
addProviders([FIREBASE_PROVIDERS, defaultFirebase(firebaseConfig)]);
inject([FirebaseApp, AngularFire], (firebaseApp: firebase.app.App, _af: AngularFire) => {
angularFire2 = _af;
app = firebaseApp;
rootRef = app.database().ref();
questionsRef = rootRef.child('questions');
listOfQuestionsRef = rootRef.child('list-of-questions');
})();
});

afterEach((done) => {
rootRef.remove()
Expand All @@ -66,19 +56,19 @@ describe('angularfire', () => {


it('should be injectable via FIREBASE_PROVIDERS', () => {
expect(angularFire2).toBeAnInstanceOf(AngularFire);
expect(angularFire2 instanceof AngularFire).toBe(true);
});

describe('.auth', () => {
it('should be an instance of AuthService', inject([AngularFire], (af:AngularFire) => {
expect(af.auth).toBeAnInstanceOf(AngularFireAuth);
expect(af.auth instanceof AngularFireAuth).toBe(true);
}));
});


describe('.database', () => {
it('should be an instance of Database', inject([AngularFire], (af:AngularFire) => {
expect(af.database).toBeAnInstanceOf(AngularFireDatabase);
expect(af.database instanceof AngularFireDatabase).toBe(true);
}));
});

Expand All @@ -91,7 +81,7 @@ describe('angularfire', () => {
describe('defaultFirebase', () => {
it('should create a provider', () => {
const provider = defaultFirebase(firebaseConfig);
expect(provider).toBeAnInstanceOf(Provider);
expect(provider instanceof Provider).toBe(true);
});
});
});
22 changes: 7 additions & 15 deletions src/auth/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@ import {ReflectiveInjector, provide, Provider} from '@angular/core';
import { Observable } from 'rxjs/Observable'
import { Observer } from 'rxjs/Observer';
import {
beforeEachProviders,
expect,
ddescribe,
describe,
inject,
it,
iit,
beforeEach
addProviders,
inject
} from '@angular/core/testing';
import 'rxjs/add/operator/do';

Expand Down Expand Up @@ -103,7 +97,7 @@ describe('FirebaseAuth', () => {
let fbAuthObserver: Observer<firebase.User>;
let windowLocation: any;

beforeEachProviders(() => {
beforeEach(() => {
windowLocation = {
hash: '',
search: '',
Expand All @@ -115,7 +109,7 @@ describe('FirebaseAuth', () => {
origin:'localhost',
href:'https://localhost/'
};
return [
addProviders([
FIREBASE_PROVIDERS,
defaultFirebase(COMMON_CONFIG),
provide(FirebaseApp, {
Expand All @@ -129,10 +123,8 @@ describe('FirebaseAuth', () => {
provide(WindowLocation, {
useValue: windowLocation
})
]
});
]);

beforeEach(() => {
authSpy = jasmine.createSpyObj('auth', authMethods);
authSpy['createUserWithEmailAndPassword'].and.returnValue(Promise.resolve(firebaseUser));
authSpy['signInWithPopup'].and.returnValue(Promise.resolve(googleCredential));
Expand Down Expand Up @@ -162,7 +154,7 @@ describe('FirebaseAuth', () => {


it('should be an observable', () => {
expect(afAuth).toBeAnInstanceOf(Observable);
expect(afAuth instanceof Observable).toBe(true);
});


Expand Down Expand Up @@ -213,7 +205,7 @@ describe('FirebaseAuth', () => {

describe('firebaseAuthConfig', () => {
it('should return a provider', () => {
expect(firebaseAuthConfig({ method: AuthMethods.Password })).toBeAnInstanceOf(Provider);
expect(firebaseAuthConfig({ method: AuthMethods.Password }) instanceof Provider).toBe(true);
});

it('should use config in login', () => {
Expand Down
9 changes: 0 additions & 9 deletions src/auth/auth_backend.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
import {
expect,
ddescribe,
describe,
it,
iit,
beforeEach
} from '@angular/core/testing';

import {
authDataToAuthState,
AuthProviders,
Expand Down
23 changes: 9 additions & 14 deletions src/database/firebase_list_factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ import {
AngularFire
} from '../angularfire2';
import {
beforeEach,
it,
iit,
ddescribe,
describe,
expect,
beforeEachProviders,
addProviders,
inject
} from '@angular/core/testing';
import * as utils from '../utils';
Expand Down Expand Up @@ -69,11 +63,12 @@ describe('FirebaseListFactory', () => {
var val3: any;
var app: firebase.app.App;

beforeEachProviders(() => [FIREBASE_PROVIDERS, defaultFirebase(firebaseConfig)]);

beforeEach(inject([FirebaseApp, AngularFire], (firebaseApp: firebase.app.App, _af: AngularFire) => {
app = firebaseApp;
}));
beforeEach(() => {
addProviders([FIREBASE_PROVIDERS, defaultFirebase(firebaseConfig)]);
inject([FirebaseApp, AngularFire], (firebaseApp: firebase.app.App, _af: AngularFire) => {
app = firebaseApp;
})();
});

afterEach(done => {
app.delete().then(done, done.fail);
Expand All @@ -83,12 +78,12 @@ describe('FirebaseListFactory', () => {

it('should accept a Firebase db url in the constructor', () => {
const list = FirebaseListFactory(`${rootFirebase}/questions`);
expect(list).toBeAnInstanceOf(FirebaseListObservable);
expect(list instanceof FirebaseListObservable).toBe(true);
});

it('should accept a Firebase db ref in the constructor', () => {
const list = FirebaseListFactory(firebase.database().refFromURL(`${rootFirebase}/questions`));
expect(list).toBeAnInstanceOf(FirebaseListObservable);
expect(list instanceof FirebaseListObservable).toBe(true);
});

});
Expand Down
26 changes: 11 additions & 15 deletions src/database/firebase_list_observable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ import {
FirebaseAppConfig,
AngularFire
} from '../angularfire2';
import {
describe,
ddescribe,
it,
iit,
beforeEach,
beforeEachProviders,
import {
addProviders,
inject
} from '@angular/core/testing';

Expand All @@ -34,14 +29,15 @@ describe('FirebaseObservable', () => {
var ref:firebase.database.Reference;
var app: firebase.app.App;

beforeEachProviders(() => [FIREBASE_PROVIDERS, defaultFirebase(firebaseConfig)]);

beforeEach(inject([FirebaseApp, AngularFire], (firebaseApp: firebase.app.App, _af: AngularFire) => {
app = firebaseApp;
ref = database().ref();
O = new FirebaseListObservable(ref, (observer:Observer<any>) => {
});
}));
beforeEach(() => {
addProviders([FIREBASE_PROVIDERS, defaultFirebase(firebaseConfig)]);
inject([FirebaseApp, AngularFire], (firebaseApp: firebase.app.App, _af: AngularFire) => {
app = firebaseApp;
ref = database().ref();
O = new FirebaseListObservable(ref, (observer:Observer<any>) => {
});
})();
});

afterEach(done => {
app.delete().then(done, done.fail);
Expand Down
23 changes: 9 additions & 14 deletions src/database/firebase_object_factory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { Subscription } from 'rxjs';
import { FirebaseObjectFactory, FirebaseObjectObservable } from './index';
import {
beforeEach,
it,
iit,
ddescribe,
describe,
expect,
beforeEachProviders,
addProviders,
inject
} from '@angular/core/testing';
import {
Expand All @@ -34,11 +28,12 @@ describe('FirebaseObjectFactory', () => {
var nextSpy: jasmine.Spy;
var app: firebase.app.App;

beforeEachProviders(() => [FIREBASE_PROVIDERS, defaultFirebase(firebaseConfig)]);

beforeEach(inject([FirebaseApp, AngularFire], (firebaseApp: firebase.app.App, _af: AngularFire) => {
app = firebaseApp;
}));
beforeEach(() => {
addProviders([FIREBASE_PROVIDERS, defaultFirebase(firebaseConfig)]);
inject([FirebaseApp, AngularFire], (firebaseApp: firebase.app.App, _af: AngularFire) => {
app = firebaseApp;
})();
});

afterEach(done => {
app.delete().then(done, done.fail);
Expand All @@ -48,12 +43,12 @@ describe('FirebaseObjectFactory', () => {

it('should accept a Firebase db url in the constructor', () => {
const object = FirebaseObjectFactory(`${rootFirebase}/questions`);
expect(object).toBeAnInstanceOf(FirebaseObjectObservable);
expect(object instanceof FirebaseObjectObservable).toBe(true);
});

it('should accept a Firebase db ref in the constructor', () => {
const object = FirebaseObjectFactory(firebase.database().ref().child(`questions`));
expect(object).toBeAnInstanceOf(FirebaseObjectObservable);
expect(object instanceof FirebaseObjectObservable).toBe(true);
});

});
Expand Down
Loading

0 comments on commit ac8c6be

Please sign in to comment.