-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: create a util directory (#3558)
* Introduces a new directory called `util` in the gulp setup. This should make the gulp setup more clear and maintainable. * The utility `task_helpers` no longer includes random utilities like for Firebase. Those have been moved to their own util file (similar as in `e2e/`) * Refactors the Github Status utility because it can be useful for other things as well (e.g upcoming coverage, payload)
- Loading branch information
1 parent
529eaf8
commit 0609e29
Showing
16 changed files
with
111 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import {task} from 'gulp'; | ||
import {DIST_ROOT} from '../constants'; | ||
import {cleanTask} from '../task_helpers'; | ||
import {cleanTask} from '../util/task_helpers'; | ||
|
||
|
||
task('clean', cleanTask(DIST_ROOT)); |
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
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import {task} from 'gulp'; | ||
import {serverTask} from '../task_helpers'; | ||
import {serverTask} from '../util/task_helpers'; | ||
|
||
|
||
task('serve', serverTask()); |
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,61 @@ | ||
const firebaseAdmin = require('firebase-admin'); | ||
const gcloud = require('google-cloud'); | ||
|
||
/** Opens a connection to the firebase realtime database. */ | ||
export function openFirebaseDashboardDatabase() { | ||
// Initialize the Firebase application with admin credentials. | ||
// Credentials need to be for a Service Account, which can be created in the Firebase console. | ||
firebaseAdmin.initializeApp({ | ||
credential: firebaseAdmin.credential.cert({ | ||
project_id: 'material2-dashboard', | ||
client_email: 'firebase-adminsdk-ch1ob@material2-dashboard.iam.gserviceaccount.com', | ||
// In Travis CI the private key will be incorrect because the line-breaks are escaped. | ||
// The line-breaks need to persist in the service account private key. | ||
private_key: (process.env['MATERIAL2_FIREBASE_PRIVATE_KEY'] || '').replace(/\\n/g, '\n') | ||
}), | ||
databaseURL: 'https://material2-dashboard.firebaseio.com' | ||
}); | ||
|
||
return firebaseAdmin.database(); | ||
} | ||
|
||
/** | ||
* Open Google Cloud Storage for screenshots. | ||
* The files uploaded to google cloud are also available to firebase storage. | ||
*/ | ||
export function openScreenshotsBucket() { | ||
let gcs = gcloud.storage({ | ||
projectId: 'material2-screenshots', | ||
credentials: { | ||
client_email: 'firebase-adminsdk-t4209@material2-screenshots.iam.gserviceaccount.com', | ||
private_key: decode(process.env['MATERIAL2_SCREENSHOT_FIREBASE_KEY']) | ||
}, | ||
}); | ||
|
||
// Reference the existing appspot bucket. | ||
return gcs.bucket('material2-screenshots.appspot.com'); | ||
} | ||
|
||
/** Opens a connection to the firebase database for screenshots. */ | ||
export function openFirebaseScreenshotsDatabase() { | ||
// Initialize the Firebase application with admin credentials. | ||
// Credentials need to be for a Service Account, which can be created in the Firebase console. | ||
let screenshotApp = firebaseAdmin.initializeApp({ | ||
credential: firebaseAdmin.credential.cert({ | ||
project_id: 'material2-screenshots', | ||
client_email: 'firebase-adminsdk-t4209@material2-screenshots.iam.gserviceaccount.com', | ||
private_key: decode(process.env['MATERIAL2_SCREENSHOT_FIREBASE_KEY']) | ||
}), | ||
databaseURL: 'https://material2-screenshots.firebaseio.com' | ||
}, 'material2-screenshots'); | ||
|
||
return screenshotApp.database(); | ||
} | ||
|
||
/** Decodes a Travis CI variable that is public in favor for PRs. */ | ||
export function decode(str: string): string { | ||
// In Travis CI the private key will be incorrect because the line-breaks are escaped. | ||
// The line-breaks need to persist in the service account private key. | ||
return (str || '').split('\\n').reverse().join('\\n').replace(/\\n/g, '\n'); | ||
} | ||
|
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,4 @@ | ||
/** Whether gulp currently runs inside of Travis as a push. */ | ||
export function isTravisPushBuild() { | ||
return process.env['TRAVIS_PULL_REQUEST'] === 'false'; | ||
} |