forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-dev-app.js
46 lines (33 loc) · 1.6 KB
/
deploy-dev-app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/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, chmod} = 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);
// Bazel by default marks output files as `readonly` to ensure hermeticity. Since we moved
// these files out of the `bazel-bin` directory, we should make them writable. This is necessary
// so that subsequent runs of this script can delete old contents from the deployment dist folder.
chmod('-R', 'u+w', distPath);
// Run the Firebase CLI to deploy the hosting target.
exec(`yarn -s firebase deploy --only hosting`);