Skip to content

Commit 27fc3b1

Browse files
devversionmmalerba
authored andcommitted
build: add script to deploy dev-app web package to firebase (#17989)
1 parent 3ca7c5a commit 27fc3b1

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

firebase.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"hosting": {
3-
"public": "dist/devapp-deploy",
3+
"public": "dist/dev-app-web-pkg",
44
"rewrites": [
55
{
66
"source": "/**/!(*.@(js|ts|html|css|json|svg|png|jpg|jpeg))",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"test-firefox": "bazel test //src/... --test_tag_filters=-e2e,-browser:chromium-local --build_tag_filters=-browser:chromium-local --build_tests_only",
2323
"lint": "yarn -s tslint && yarn -s bazel:format-lint && yarn -s ownerslint",
2424
"e2e": "bazel test //src/... --test_tag_filters=e2e",
25-
"deploy": "echo 'Not supported yet. Tracked with COMP-230'",
25+
"deploy-dev-app": "node ./scripts/deploy-dev-app.js",
2626
"webdriver-manager": "webdriver-manager",
2727
"breaking-changes": "ts-node --project scripts scripts/breaking-changes.ts",
2828
"gulp": "gulp",

scripts/deploy-dev-app.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Script that builds the dev-app as a static web package that will be
5+
* deployed to the currently configured Firebase project.
6+
*/
7+
8+
const {exec, set, cd, cp, rm} = require('shelljs');
9+
const {join} = require('path');
10+
11+
// ShellJS should throw if any command fails.
12+
set('-e');
13+
14+
/** Path to the project directory. */
15+
const projectDirPath = join(__dirname, '../');
16+
17+
// Go to project directory.
18+
cd(projectDirPath);
19+
20+
/** Path to the bazel-bin directory. */
21+
const bazelBinPath = exec(`yarn -s bazel info bazel-bin`).stdout.trim();
22+
23+
/** Output path for the Bazel dev-app web package target. */
24+
const webPackagePath = join(bazelBinPath, 'src/dev-app/web_package');
25+
26+
/** Destination path where the web package should be copied to. */
27+
const distPath = join(projectDirPath, 'dist/dev-app-web-pkg');
28+
29+
// Build web package output.
30+
exec('yarn -s bazel build //src/dev-app:web_package');
31+
32+
// Clear previous deployment artifacts.
33+
rm('-Rf', distPath);
34+
35+
// Copy the web package from the bazel-bin directory to the project dist
36+
// path. This is necessary because the Firebase CLI does not support deployment
37+
// of a public folder outside of the "firebase.json" file.
38+
cp('-R', webPackagePath, distPath);
39+
40+
// Run the Firebase CLI to deploy the hosting target.
41+
exec(`yarn -s firebase deploy --only hosting`);

0 commit comments

Comments
 (0)