Skip to content

Commit

Permalink
refactor(database): Implement database in Typescript (#72)
Browse files Browse the repository at this point in the history
* refactor(database): remove old database implementation [Part 1/3] (#61)

* refactor(database): remove old database implementation

This is part #1 of 4 PR's to migrate database

* refactor(database): remove database build processes

* refactor(database): Add typescript database implementation [Part 2/3] (#62)

* refactor(database): add typescript implementation

* refactor(database): update build process to include database.ts

All integration tests pass at this point

* refactor(*): refactor environment builds to be based on separate .ts files

* WIP: patch database code in nodeJS

* refactor(database): classes for typescript database implementation (#55)

* refactor(database): classes for typescript database implementation

* refactor(database): requested changes & other improvements

* fix(database): Add missing "typeof" (#74)

https://github.com/firebase/firebase-js-sdk/blob/fd0728138d88c454f8e38a78f35d831d6365070c/src/database/js-client/core/Repo.js#L86

* WIP: fixes from @schmidt-sebastian's review

* WIP: fix: TS Build error

* fix(database): fix issue with missing repo method

* WIP: review adjustments #1

* WIP: review comments #2

* WIP: refactor(database): Add migrated test harness [Part 3/3] (#71)

* refactor(database): add typescript implementation

* refactor(database): update build process to include database.ts

All integration tests pass at this point

* refactor(*): refactor environment builds to be based on separate .ts files

* WIP: patch database code in nodeJS

* refactor(database): classes for typescript database implementation (#55)

* refactor(database): classes for typescript database implementation

* refactor(database): requested changes & other improvements

* WIP: add the /tests/config dir to the .gitignore

* WIP: add test harness

* WIP: add query tests

There are some tests that have weird timing issues, and because of the polling nature of the
original implementation, we never caught the issue. These should be resolved when able

* WIP: add database.test.ts

* WIP: add node.test.ts

* WIP: add sortedmap.test.ts

* WIP: add datasnapshot.test.ts

* WIP: add sparsesnapshottree.test.ts

* refactor(database): refactor query.test.ts to better preserve original test meaning

* WIP: add crawler_support.test.ts

* WIP: refactor EventAccumulator.ts for data.test.ts

* WIP: fix issue with query.test.ts

* WIP: add connection.test.ts

* WIP: add info.test.ts

* WIP: add order_by.test.ts

I only migrated some of these tests as there was a dependency on the server for several tests

* WIP: fix several code signature problems, add test files

* WIP: add transaction.test.ts

* WIP: working on the broken npm test command

* WIP: working on fixes

* WIP: remove logging

* WIP: fix node tests

* fix(*): fixing test files and CI integration

* WIP: tEMP: Allow branch builds

* WIP: escape string

* refactor(CI): use ChromeHeadless launcher

* WIP: fixes from review.

* WIP: skip flakey test

* WIP: remove unneeded debugger statement

* WIP: fixing nits

* Prevent using uninitialized array in EventEmitter (#85)

* perf(*): fixing build size output issues

* chore(*): remove unneeded build deps
  • Loading branch information
jshcrowthe authored Jul 6, 2017
1 parent 6aaef70 commit a8919cd
Show file tree
Hide file tree
Showing 2,652 changed files with 25,830 additions and 662,814 deletions.
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

0 comments on commit a8919cd

Please sign in to comment.