Skip to content

Commit 7c57f82

Browse files
authored
build: initial attempt to fix docs site deployment (angular#30372)
This fixes a few issues: - uses the monorepo checked-in docs sources for deployment of >=v19 - properly installs dependencies for that repository, avoiding mismatches with the checked-in yarn of the monorepo root. - avoids sandbox when launching puppeteer for audits
1 parent 9ad4855 commit 7c57f82

File tree

5 files changed

+570
-39
lines changed

5 files changed

+570
-39
lines changed

material.angular.io/tools/lighthouse-audit.mjs

+8-6
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ async function _main(args) {
111111
onError('Lighthouse failed to return any results.');
112112
}
113113
const success = await processResults(results, minScores, logFile);
114-
console.log(`\nCompleted audit of ${url} in ${((Date.now() - startTime) / 1000).toFixed(1)}s\n`);
114+
console.log(
115+
`\nCompleted audit of ${url} in ${((Date.now() - startTime) / 1000).toFixed(1)}s\n`,
116+
);
115117

116118
if (!success) {
117119
onError('One or more scores are below the minimum required.');
@@ -191,12 +193,12 @@ function parseInput(args) {
191193
if (unknownCategories.length > 0) {
192194
onError(
193195
`Invalid arguments: <min-scores> contains unknown category(-ies): ${unknownCategories.join(
194-
', '
195-
)}`
196+
', ',
197+
)}`,
196198
);
197199
} else if (!allValuesValid) {
198200
onError(
199-
`Invalid arguments: <min-scores> has non-numeric or out-of-range values: ${minScoresRaw}`
201+
`Invalid arguments: <min-scores> has non-numeric or out-of-range values: ${minScoresRaw}`,
200202
);
201203
}
202204

@@ -232,7 +234,7 @@ function parseMinScores(raw) {
232234

233235
if (minScores.hasOwnProperty('all')) {
234236
AUDIT_CATEGORIES.forEach(
235-
cat => minScores.hasOwnProperty(cat) || (minScores[cat] = minScores.all)
237+
cat => minScores.hasOwnProperty(cat) || (minScores[cat] = minScores.all),
236238
);
237239
delete minScores.all;
238240
}
@@ -273,7 +275,7 @@ async function processResults(results, minScores, logFile) {
273275
console.log(
274276
` - ${paddedTitle} ${formatScore(score)} (Required: ${formatScore(minScore)}) ${
275277
passed ? 'OK' : 'FAILED'
276-
}`
278+
}`,
277279
);
278280

279281
return aggr && passed;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"@angular/cli": "^19.1.0-rc.0",
8080
"@angular/compiler-cli": "^19.1.0-rc.0",
8181
"@angular/localize": "^19.1.0-rc.0",
82-
"@angular/ng-dev": "https://github.com/angular/dev-infra-private-ng-dev-builds.git#36946be4df61f6549ae3829c026022e47674eae2",
82+
"@angular/ng-dev": "https://github.com/angular/dev-infra-private-ng-dev-builds.git#1fa3a08b6a111de820da092799319ed47c058849",
8383
"@angular/platform-browser-dynamic": "^19.1.0-rc.0",
8484
"@angular/platform-server": "^19.1.0-rc.0",
8585
"@angular/router": "^19.1.0-rc.0",

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

+6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ export const docsRepoUrl = 'https://github.com/angular/material.angular.io.git';
1313
*
1414
* @returns An absolute path to the temporary directory.
1515
*/
16+
// TODO: Remove this function as it shouldn't be needed long term.
1617
export async function cloneDocsRepositoryForMajor(major: number): Promise<string> {
18+
// As for v19, we use the checked-in code inside the monorepo.
19+
if (major >= 19) {
20+
return path.join(projectDir, 'material.angular.io');
21+
}
22+
1723
const repoTmpDir = path.join(projectDir, 'tmp/docs-repo');
1824
const baseCloneArgs = [docsRepoUrl, repoTmpDir, '--single-branch', '--depth=1'];
1925
const majorDocsBranchName = getDocsBranchNameForMajor(major);

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {$} from 'zx';
1+
import {$, cd} from 'zx';
2+
import {resolveYarnScriptForProject} from '@angular/ng-dev';
23

34
export interface InstallOptions {
45
/** Whether dependencies should be installed with the lockfile being frozen. */
@@ -10,11 +11,12 @@ export async function installDepsForDocsSite(
1011
repoDirPath: string,
1112
options: InstallOptions = {frozenLockfile: true},
1213
) {
14+
const yarnBin = await resolveYarnScriptForProject(repoDirPath);
1315
const additionalArgs = [];
1416

1517
if (options.frozenLockfile) {
16-
additionalArgs.push('--frozen-lockfile');
18+
additionalArgs.push(yarnBin.legacy ? '--frozen-lock-file' : '--immutable');
1719
}
1820

19-
await $`yarn --cwd ${repoDirPath} install ${additionalArgs}`;
21+
await $`${yarnBin.binary} ${yarnBin.args} --cwd ${repoDirPath} install ${additionalArgs}`;
2022
}

0 commit comments

Comments
 (0)