Skip to content

build: add script to deploy dev-app web package to firebase #17989

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
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion firebase.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"hosting": {
"public": "dist/devapp-deploy",
"public": "dist/dev-app-web-pkg",
"rewrites": [
{
"source": "/**/!(*.@(js|ts|html|css|json|svg|png|jpg|jpeg))",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"test-firefox": "bazel test //src/... --test_tag_filters=-e2e,-browser:chromium-local --build_tag_filters=-browser:chromium-local --build_tests_only",
"lint": "yarn -s tslint && yarn -s bazel:format-lint && yarn -s ownerslint",
"e2e": "bazel test //src/... --test_tag_filters=e2e",
"deploy": "echo 'Not supported yet. Tracked with COMP-230'",
"deploy-dev-app": "node ./scripts/deploy-dev-app.js",
"webdriver-manager": "webdriver-manager",
"breaking-changes": "ts-node --project scripts scripts/breaking-changes.ts",
"gulp": "gulp",
Expand Down
41 changes: 41 additions & 0 deletions scripts/deploy-dev-app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env node

/**
* Script that builds the dev-app as a static web package that will be
* deployed to the currently configured Firebase project.
*/

const {exec, set, cd, cp, rm} = require('shelljs');
const {join} = require('path');

// ShellJS should throw if any command fails.
set('-e');

/** Path to the project directory. */
const projectDirPath = join(__dirname, '../');

// Go to project directory.
cd(projectDirPath);

/** Path to the bazel-bin directory. */
const bazelBinPath = exec(`yarn -s bazel info bazel-bin`).stdout.trim();

/** Output path for the Bazel dev-app web package target. */
const webPackagePath = join(bazelBinPath, 'src/dev-app/web_package');

/** Destination path where the web package should be copied to. */
const distPath = join(projectDirPath, 'dist/dev-app-web-pkg');

// Build web package output.
exec('yarn -s bazel build //src/dev-app:web_package');

// Clear previous deployment artifacts.
rm('-Rf', distPath);

// Copy the web package from the bazel-bin directory to the project dist
// path. This is necessary because the Firebase CLI does not support deployment
// of a public folder outside of the "firebase.json" file.
cp('-R', webPackagePath, distPath);

// Run the Firebase CLI to deploy the hosting target.
exec(`yarn -s firebase deploy --only hosting`);