Skip to content

refactor(database): Implement database in Typescript #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
npm-debug.log
/coverage
/.nyc_output
/tests/integration/config
/tests/config
/temp
/.vscode
/.ts-node
/.idea
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ addons:
- g++-4.8
before_script:
- "export DISPLAY=:99.0"
- "mkdir -p tests/config && echo \"$PROJECT_CONFIG\" > tests/config/project.json"
script:
- xvfb-run npm test
branches:
only:
- master
26 changes: 20 additions & 6 deletions gulp/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ const path = require('path');
const cwd = process.cwd();
const karma = require('karma');

module.exports = {
const configObj = {
root: path.resolve(cwd),
pkg: require(path.resolve(cwd, 'package.json')),
testConfig: {
timeout: 5000,
retries: 5
},
tsconfig: require(path.resolve(cwd, 'tsconfig.json')),
tsconfigTest: require(path.resolve(cwd, 'tsconfig.test.json')),
paths: {
Expand All @@ -30,6 +34,7 @@ module.exports = {
'tests/**/*.test.ts',
'!tests/**/browser/**/*.test.ts',
'!tests/**/binary/**/*.test.ts',
'!src/firebase-*.ts',
],
binary: [
'tests/**/binary/**/*.test.ts',
Expand All @@ -44,11 +49,10 @@ module.exports = {
},
babel: {
plugins: [
require('babel-plugin-add-module-exports'),
require('babel-plugin-minify-dead-code-elimination')
'add-module-exports',
],
presets: [
[require('babel-preset-env'), {
['env', {
"targets": {
"browsers": [
"ie >= 9"
Expand Down Expand Up @@ -103,7 +107,7 @@ module.exports = {

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome', 'Firefox'],
browsers: ['ChromeHeadless', 'Firefox'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
Expand All @@ -116,6 +120,16 @@ module.exports = {
// karma-typescript config
karmaTypescriptConfig: {
tsconfig: `./tsconfig.test.json`
},

// Stub for client config
client: {
mocha: {}
}
}
};
};

configObj.karma.client.mocha.timeout = configObj.testConfig.timeout;
configObj.karma.client.mocha.retries = configObj.testConfig.retries;

module.exports = configObj;
68 changes: 15 additions & 53 deletions gulp/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const glob = require('glob');
const fs = require('fs');
const gzipSize = require('gzip-size');
const WrapperPlugin = require('wrapper-webpack-plugin');
const legacyBuild = require('./build.legacy');

function cleanDist(dir) {
return function cleanDistDirectory(done) {
Expand Down Expand Up @@ -135,11 +134,12 @@ function compileIndvES2015ModulesToBrowser() {
'firebase-app': './src/app.ts',
'firebase-storage': './src/storage.ts',
'firebase-messaging': './src/messaging.ts',
'firebase-database': './src/database.ts',
},
output: {
path: path.resolve(__dirname, './dist/browser'),
filename: '[name].js',
jsonpFunction: 'webpackJsonpFirebase'
jsonpFunction: 'webpackJsonpFirebase',
path: path.resolve(__dirname, './dist/browser'),
},
module: {
rules: [{
Expand All @@ -158,6 +158,7 @@ function compileIndvES2015ModulesToBrowser() {
}]
},
plugins: [
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'firebase-app'
}),
Expand Down Expand Up @@ -193,27 +194,6 @@ function compileIndvES2015ModulesToBrowser() {
.pipe(gulp.dest(`${config.paths.outDir}/browser`));
}

function compileSDKES2015ToBrowser() {
return gulp.src('./dist/es2015/firebase.js')
.pipe(webpackStream({
plugins: [
new webpack.DefinePlugin({
TARGET_ENVIRONMENT: JSON.stringify('browser')
})
]
}, webpack))
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(through.obj(function(file, enc, cb) {
// Dont pipe through any source map files as it will be handled
// by gulp-sourcemaps
var isSourceMap = /\.map$/.test(file.path);
if (!isSourceMap) this.push(file);
cb();
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(`${config.paths.outDir}/browser`));
}

function buildBrowserFirebaseJs() {
return gulp.src('./dist/browser/*.js')
.pipe(sourcemaps.init({ loadMaps: true }))
Expand All @@ -223,32 +203,18 @@ function buildBrowserFirebaseJs() {
}

function buildAltEnvFirebaseJs() {
const envs = [
'browser',
'node',
'react-native'
];

const streams = envs.map(env => {
const babelConfig = Object.assign({}, config.babel, {
plugins: [
['inline-replace-variables', {
'TARGET_ENVIRONMENT': env
}],
...config.babel.plugins
]
});
return gulp.src('./dist/es2015/firebase.js')
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(babel(babelConfig))
.pipe(rename({
suffix: `-${env}`
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(`${config.paths.outDir}/cjs`));
const babelConfig = Object.assign({}, config.babel, {
plugins: config.babel.plugins
});

return merge(streams);
return gulp.src([
'./dist/es2015/firebase-browser.js',
'./dist/es2015/firebase-node.js',
'./dist/es2015/firebase-react-native.js',
])
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(babel(babelConfig))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(`${config.paths.outDir}/cjs`));
}

function copyPackageContents() {
Expand Down Expand Up @@ -429,7 +395,6 @@ gulp.task('build:cjs', gulp.parallel([
gulp.parallel(compileES2015ToCJS, buildAltEnvFirebaseJs)
]),
processPrebuiltFilesForCJS,
legacyBuild.compileDatabaseForCJS
]));

gulp.task('process:prebuilt', gulp.parallel([
Expand All @@ -444,8 +409,6 @@ const compileSourceAssets = gulp.series([
gulp.parallel([
compileIndvES2015ModulesToBrowser,
compileES2015ToCJS,
legacyBuild.compileDatabaseForBrowser,
legacyBuild.compileDatabaseForCJS
])
]);

Expand All @@ -455,7 +418,6 @@ gulp.task('build:browser', gulp.series([
gulp.parallel([
compileSourceAssets,
processPrebuiltFilesForBrowser,
legacyBuild.compileDatabaseForBrowser
]),
buildBrowserFirebaseJs
]));
Expand Down
141 changes: 0 additions & 141 deletions gulp/tasks/build.legacy.js

This file was deleted.

9 changes: 4 additions & 5 deletions gulp/tasks/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@ const gulp = require('gulp');
const config = require('../config');

// Ensure that the test tasks get set up
require('./test');
const testFxns = require('./test');

function watchDevFiles() {
const stream = gulp.watch([
`${config.root}/src/**/*.ts`,
config.paths.test.unit
], gulp.parallel('test:unit'));
'tests/**/*.test.ts'
], testFxns.runBrowserUnitTests(true));

stream.on('error', () => {});
stream.on('error', err => {});
return stream;
}

gulp.task('dev', gulp.parallel([
'test:unit',
watchDevFiles
]));
Loading