|
| 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