-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from firebase/next
04/07/2020 Release
- Loading branch information
Showing
42 changed files
with
564 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Development Setup | ||
|
||
The firestore-bigquery-export extension is split out into 4 node.js packages, three of | ||
which are hosted on [npm](https://www.npmjs.com/search?q=firebaseextensions). | ||
|
||
**[firestore-bigquery-change-tracker](https://www.npmjs.com/package/@firebaseextensions/firestore-bigquery-change-tracker)**: | ||
Contains the core interface defintions for document changes. Also exposes an | ||
API for uploading changes to BigQuery. The business-logic associated with | ||
creating the raw changelog and the latest snapshot of live documents in the | ||
changelog also lives in this package. | ||
|
||
**[fs-bq-import-collection](https://www.npmjs.com/package/@firebaseextensions/fs-bq-import-collection)**: | ||
Contains a script for resumably importing a firestore collection into BigQuery | ||
using the interface definitions in `firestore-bigquery-change-tracker`. | ||
|
||
**[fs-bq-schema-views](https://www.npmjs.com/package/@firebaseextensions/fs-bq-schema-views)**: | ||
Contains a script for generating BigQuery views that provide typed-checked | ||
access to the changelog created in `firestore-bigquery-change-tracker`. | ||
|
||
**firestore-bigquery-export-functions (not hosted)**: Contains the definition | ||
for a Google Cloud function that is called on each write to some collection. | ||
The function constructs the relevant change event and calls the API in | ||
`firestore-bigquery-change-tracker` to upload the change to BigQuery. | ||
|
||
Here are the dependency edges: | ||
|
||
1. [fs-bq-import-collection -> firestore-bigquery-change-tracker](https://github.com/firebase/extensions/blob/next/firestore-bigquery-export/scripts/import/package.json#L27) | ||
1. [firestore-bigquery-export-functions -> firestore-bigquery-change-tracker](https://github.com/firebase/extensions/blob/next/firestore-bigquery-export/package.json#L17) | ||
|
||
Note that `fs-bq-schema-views` is a standalone package, and all of these | ||
packages are included at the root of this extension's folder in the firebase | ||
extensions repo. | ||
|
||
## Building Locally | ||
|
||
### Clean up any local changes (optional) | ||
|
||
Make sure you've cleaned up and partial builds: | ||
|
||
``` | ||
export PKGS="firestore-bigquery-change-tracker scripts/gen-schema-view scripts/import functions ." | ||
for pkg in $PKGS; | ||
do | ||
pushd . && cd $pkg && npm run clean && rm -rf node_modules | ||
popd | ||
done; | ||
``` | ||
|
||
### Local package.json file pointers | ||
|
||
Npm supports using [local paths as | ||
dependencies](https://docs.npmjs.com/files/package.json#local-paths) in package.json. | ||
You'll need to update the following package.json files with local pointers to | ||
the firestore-bigquery-change-tracker package: | ||
|
||
1. firestore-bigquery-export/package.json | ||
1. firestore-bigquery-export/scripts/import/package.json | ||
|
||
This can be done with jq from the root of this extension's folder: | ||
|
||
``` | ||
jq '.dependencies."@firebaseextensions/firestore-bigquery-change-tracker" = "file:./firestore-bigquery-change-tracker"' package.json > package.local.json | ||
jq '.dependencies."@firebaseextensions/firestore-bigquery-change-tracker" = "file:../../firestore-bigquery-change-tracker"' scripts/import/package.json > scripts/import/package.local.json | ||
mv package.json package.json.bak | ||
mv scripts/import/package.json scripts/import/package.remote.json.bak | ||
mv package.local.json package.json | ||
mv scripts/import/package.local.json scripts/import/package.json | ||
``` | ||
|
||
Now, build the components according to the dependency order. | ||
|
||
``` | ||
export PKGS="firestore-bigquery-change-tracker scripts/import . scripts/gen-schema-view" | ||
for pkg in $PKGS; | ||
do | ||
pushd . && cd $pkg && npm install && npm run build | ||
popd | ||
done; | ||
``` | ||
|
||
Finally, you can install the extension you just built onto a Firebase-enabled | ||
GCP project with: | ||
|
||
``` | ||
firebase ext:install ./firestore-bigquery-export --project=project-id | ||
``` | ||
|
||
## Publishing | ||
|
||
_The following instructions are for Firebase team members only._ | ||
|
||
We publish 3 separate npm packages for this extension. Each follows semver, so | ||
make sure to update the version numbers and corresponding dependencies. | ||
|
||
For each package, `cd` into the appropriate directory, then run: | ||
|
||
``` | ||
npm pack | ||
npm publish | ||
``` | ||
|
||
In general, you should publish `firestore-bigquery-change-tracker` first, since | ||
it doesn't depend on anything else. You should also only publish _after_ your | ||
changes have been merged into the `next` branch (and before the extension is | ||
released). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
firestore-bigquery-export/docs/images/firestore-bigquery-export-dep-diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
firestore-bigquery-export/firestore-bigquery-change-tracker/mocha.opts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,19 +5,19 @@ | |
"url": "github.com/firebase/extensions.git", | ||
"directory": "firestore-bigquery-export/firestore-bigquery-change-tracker" | ||
}, | ||
"version": "1.0.1", | ||
"version": "1.1.2", | ||
"description": "Core change-tracker library for Cloud Firestore Collection BigQuery Exports", | ||
"main": "./lib/index.js", | ||
"scripts": { | ||
"build": "npm run clean && npm run compile", | ||
"clean": "rimraf functions/lib", | ||
"clean": "rimraf lib", | ||
"compile": "tsc", | ||
"mocha": "nyc mocha -r ts-node/register --opts mocha.opts", | ||
"test": "npm run mocha", | ||
"test": "jest", | ||
"prepare": "npm run build" | ||
}, | ||
"files": [ | ||
"lib" | ||
"lib/*.js", | ||
"lib/bigquery/*.js" | ||
], | ||
"author": "Jan Wyszynski <[email protected]>", | ||
"license": "Apache-2.0", | ||
|
@@ -31,13 +31,14 @@ | |
"sql-formatter": "^2.3.3" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.2.0", | ||
"typescript": "^3.4.5", | ||
"rimraf": "^2.6.3", | ||
"mocha": "^5.0.5", | ||
"nyc": "^14.0.0", | ||
"@types/chai": "^4.1.6", | ||
"@types/mocha": "^5.2.5", | ||
"jest": "^24.9.0", | ||
"chai": "^4.2.0", | ||
"ts-node": "^7.0.1", | ||
"typescript": "^3.4.5" | ||
"ts-jest": "^24.1.0", | ||
"@types/jest": "^24.0.18", | ||
"@types/chai": "^4.1.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.