mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
We automatically generate the sitemap for the angular.dev deployment and include it in the assets pushed to firebase. Co-authored-by: Matthieu Riegler <kyro38@gmail.com>
73 lines
2.2 KiB
TypeScript
73 lines
2.2 KiB
TypeScript
import {fetchLongTermSupportBranchesFromNpm, ActiveReleaseTrains} from '@angular/ng-dev';
|
|
import {ReleaseConfig} from '@angular/ng-dev';
|
|
import {AuthenticatedGitClient} from '@angular/ng-dev';
|
|
|
|
export interface Deployment {
|
|
branch: string;
|
|
redirect?: {
|
|
from: string;
|
|
to: string;
|
|
};
|
|
destination?: string;
|
|
servingUrl: string;
|
|
}
|
|
|
|
export type Deployments = Map<string, Deployment>;
|
|
|
|
export async function getDeployments(): Promise<Deployments> {
|
|
const {github} = await AuthenticatedGitClient.get();
|
|
const releaseTrains = await ActiveReleaseTrains.fetch({
|
|
api: github,
|
|
name: 'angular',
|
|
owner: 'angular',
|
|
nextBranchName: 'main',
|
|
});
|
|
const ltsBranches = await fetchLongTermSupportBranchesFromNpm({
|
|
representativeNpmPackage: '@angular/core',
|
|
} as ReleaseConfig);
|
|
|
|
const docSites = new Map<string, Deployment>();
|
|
|
|
[...ltsBranches.active, ...ltsBranches.inactive].forEach((branch) => {
|
|
docSites.set(branch.name, {
|
|
branch: branch.name,
|
|
destination: `v${branch.version.major}-angular-dev`,
|
|
servingUrl: `https://v${branch.version.major}.angular.dev/`,
|
|
});
|
|
});
|
|
|
|
docSites.set(releaseTrains.latest.branchName, {
|
|
branch: releaseTrains.latest.branchName,
|
|
redirect: {
|
|
from: `v${releaseTrains.latest.version.major}-angular-dev`,
|
|
to: 'https://angular.dev',
|
|
},
|
|
servingUrl: 'https://angular.dev/',
|
|
destination: 'angular-dev-site',
|
|
});
|
|
|
|
if (releaseTrains.releaseCandidate) {
|
|
docSites.set(releaseTrains.next.branchName, {
|
|
branch: releaseTrains.next.branchName,
|
|
servingUrl: 'https://next.angular.dev/',
|
|
});
|
|
|
|
docSites.set(releaseTrains.releaseCandidate.branchName, {
|
|
branch: releaseTrains.releaseCandidate.branchName,
|
|
destination: 'next-angular-dev',
|
|
redirect: {
|
|
from: `v${releaseTrains.releaseCandidate.version.major}-angular-dev`,
|
|
to: 'https://next.angular.dev',
|
|
},
|
|
servingUrl: 'https://next.angular.dev/',
|
|
});
|
|
} else {
|
|
docSites.set(releaseTrains.next.branchName, {
|
|
branch: releaseTrains.next.branchName,
|
|
destination: 'next-angular-dev',
|
|
servingUrl: 'https://next.angular.dev/',
|
|
});
|
|
}
|
|
|
|
return docSites;
|
|
}
|