Skip to content

Commit d144ee6

Browse files
committed
build: update docs deployment to use bazel monorepo
Updates docs deployment to rely on the Bazel monorepo.
1 parent 1fe4eb8 commit d144ee6

9 files changed

+29
-151
lines changed

docs/firebase.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://raw.githubusercontent.com/firebase/firebase-tools/master/schema/firebase-config.json",
33
"hosting": {
44
"target": "mat-aio",
5-
"public": "dist/material-angular-io",
5+
"public": "./dist/material-angular-io.production",
66
"cleanUrls": true,
77
"rewrites": [
88
{

scripts/docs-deploy/clone-docs-repo.mts

-68
This file was deleted.

scripts/docs-deploy/deploy-ci-push.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async function main() {
6262
// For the stable deployment, we want to update the versions file which is loaded
6363
// by all docs sites (archives, rc, next etc.). The source of truth for all versions
6464
// shown in the "docs version picker" is the versions file deployed in stable.
65-
prebuild: docsRepoDir => updateVersionsFile(docsRepoDir, active),
65+
prebuild: workspaceDir => updateVersionsFile(workspaceDir, active),
6666
});
6767
return;
6868
}

scripts/docs-deploy/deploy-to-site.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export async function deployToSite(
4040
info: DeploymentInfo,
4141
) {
4242
const firebase = async (...cmd: string[]) =>
43-
$`yarn --cwd ${projectPath} firebase --non-interactive ${cmd}`;
43+
$`pnpm --dir=${projectPath}/docs firebase --non-interactive ${cmd}`;
4444

4545
// Setup GCP service key for the docs-app deployment.
4646
// https://firebase.google.com/docs/admin/setup.

scripts/docs-deploy/docs-deps-install.mts

-24
This file was deleted.
+7-16
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,27 @@
11
import {$, cd} from 'zx';
22

3+
import path from 'node:path';
34
import {ProductionDeployment} from '../deploy-to-site.mjs';
4-
import {cloneDocsRepositoryForMajor} from '../clone-docs-repo.mjs';
5-
import {ActiveReleaseTrains} from '@angular/ng-dev';
6-
import {getReleaseRepoWithApi} from '../github-versioning.mjs';
7-
import {installDepsForDocsSite} from '../docs-deps-install.mjs';
8-
import {sites} from '../utils.mjs';
5+
import {projectDir, sites} from '../utils.mjs';
96

107
/**
118
* Runs monitoring tests for the given docs repository, ensuring that the
129
* specified remote URL is properly functioning.
1310
*/
14-
export async function runMonitorTests(docsRepoDir: string, remoteUrl: string) {
15-
cd(docsRepoDir);
11+
export async function runMonitorTests(remoteUrl: string) {
12+
cd(path.join(projectDir, 'docs'));
1613

1714
await $`node ./tools/audit-docs.js ${remoteUrl}`;
1815
}
1916

2017
/** Runs the monitoring tests for the stable release train. */
2118
export async function runMonitorTestsForStable() {
22-
const repo = await getReleaseRepoWithApi();
23-
const active = await ActiveReleaseTrains.fetch(repo);
24-
const stableMajor = active.latest.version.major;
25-
const docsRepoDir = await cloneDocsRepositoryForMajor(stableMajor);
26-
27-
await installDepsForDocsSite(docsRepoDir);
28-
await runMonitorTests(docsRepoDir, sites.stable.remoteUrl);
19+
await runMonitorTests(sites.stable.remoteUrl);
2920
}
3021

3122
/** Runs monitoring tests for all specified production deployments. */
32-
export async function runMonitoringTests(docsRepoDir: string, targets: ProductionDeployment[]) {
23+
export async function runMonitoringTests(targets: ProductionDeployment[]) {
3324
for (const target of targets) {
34-
await runMonitorTests(docsRepoDir, target.site.remoteUrl);
25+
await runMonitorTests(target.site.remoteUrl);
3526
}
3627
}
+7-29
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
import {DeploymentInfo, deployToSite, isProductionDeployment} from './deploy-to-site.mjs';
22

3-
import {buildDocsContentPackage} from '../build-docs-content.mjs';
4-
import {cloneDocsRepositoryForMajor} from './clone-docs-repo.mjs';
5-
import {installBuiltPackagesInRepo} from './install-built-packages.mjs';
6-
import {installDepsAndBuildDocsSite} from './utils.mjs';
7-
import {performDefaultSnapshotBuild} from '../build-packages-dist.mjs';
83
import {runMonitoringTests} from './monitoring/index.mjs';
4+
import {buildDocsSite, projectDir} from './utils.mjs';
95

106
export type DeploymentConfig = {
117
/**
128
* Optional hook running before building the docs-app for deployment.
13-
*
14-
* Runs after the docs-content and local packages have been installed
15-
* in the docs repository.
169
*/
17-
prebuild?: (docsRepoDir: string) => Promise<void> | void;
10+
prebuild?: (workspaceDir: string) => Promise<void> | void;
1811
};
1912

2013
/**
@@ -48,32 +41,17 @@ export async function buildAndDeployWithSnapshots(
4841
console.log(` - ${target.projectId}:${target.site.firebaseSiteId} | ${target.site.remoteUrl}`);
4942
}
5043

51-
// Clone the docs repo.
52-
const docsRepoDir = await cloneDocsRepositoryForMajor(major);
53-
54-
// Build the release output.
55-
const builtPackages = performDefaultSnapshotBuild();
56-
57-
// Build the docs-content NPM package (not included in the default snapshot build)
58-
builtPackages.push(buildDocsContentPackage());
59-
60-
// Install the release output, together with the examples into the
61-
// the docs repository.
62-
await installBuiltPackagesInRepo(docsRepoDir, builtPackages);
63-
6444
// Run the prebuild hook if available.
65-
await options.prebuild?.(docsRepoDir);
45+
await options.prebuild?.(projectDir);
6646

67-
// Install yarn dependencies and build the production output.
68-
// Lockfile freezing needs to be disabled since we updated the `package.json`
69-
// to point to our locally-built package artifacts.
70-
await installDepsAndBuildDocsSite(docsRepoDir, {frozenLockfile: false});
47+
// Build the production output (we always use HEAD packages).
48+
await buildDocsSite();
7149

7250
// Deploy all targets to Firebase.
7351
for (const target of targets) {
74-
await deployToSite(docsRepoDir, firebaseServiceKey, target);
52+
await deployToSite(projectDir, firebaseServiceKey, target);
7553
}
7654

7755
// Run post monitoring tests for production deployments.
78-
await runMonitoringTests(docsRepoDir, targets.filter(isProductionDeployment));
56+
await runMonitoringTests(targets.filter(isProductionDeployment));
7957
}

scripts/docs-deploy/update-versions-file.mts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface VersionEntry {
1818
type VersionList = VersionEntry[];
1919

2020
/** Path to the `versions.json` file in the docs-app. */
21-
const relativeVersionFilePath = 'src/assets/versions.json';
21+
const relativeVersionFilePath = 'docs/src/assets/versions.json';
2222

2323
/**
2424
* List of hard-coded major versions which have an archived docs-site,
@@ -33,8 +33,8 @@ const hardcodedOldMajorsWithoutLtsTag = [5, 6, 7, 8, 9, 10, 11];
3333
* Updates the versions list file in the specified docs repo to reflect
3434
* the current active release trains and archived LTS versions.
3535
*/
36-
export async function updateVersionsFile(docsRepoDir: string, active: ActiveReleaseTrains) {
37-
const versionFilePath = path.join(docsRepoDir, relativeVersionFilePath);
36+
export async function updateVersionsFile(workspaceDir: string, active: ActiveReleaseTrains) {
37+
const versionFilePath = path.join(workspaceDir, relativeVersionFilePath);
3838
const {release} = await getConfig([assertValidReleaseConfig]);
3939
const ltsBranches = await fetchLongTermSupportBranchesFromNpm(release);
4040

scripts/docs-deploy/utils.mts

+9-8
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import * as fs from 'fs';
22
import * as path from 'path';
33
import {fileURLToPath} from 'url';
44

5-
import {InstallOptions, installDepsForDocsSite} from './docs-deps-install.mjs';
6-
7-
import {$} from 'zx';
5+
import {$, cd} from 'zx';
86

97
/** Absolute path to the `angular/components` project root. */
108
export const projectDir = path.join(path.dirname(fileURLToPath(import.meta.url)), '../..');
@@ -50,10 +48,13 @@ export async function getPackageJsonOfProject(
5048
}
5149

5250
/**
53-
* Installs dependencies in the specified docs repository and builds the
54-
* production site output.
51+
* Builds the docs site in production.
5552
*/
56-
export async function installDepsAndBuildDocsSite(repoPath: string, options: InstallOptions) {
57-
await installDepsForDocsSite(repoPath, options);
58-
await $`yarn --cwd ${repoPath} prod-build`;
53+
export async function buildDocsSite() {
54+
cd(projectDir);
55+
await $`pnpm bazel build --config=snapshot-build //docs:build.production`;
56+
await $`rm -Rf docs/dist`;
57+
await $`mkdir -p docs/dist`;
58+
await $`cp -R dist/bin/docs/material-angular-io.production docs/dist`;
59+
await $`chmod -R u+w docs/dist/material-angular-io.production`;
5960
}

0 commit comments

Comments
 (0)