Files
github-actions-magento2/supported-version/src/matrix/get-matrix-for-versions.ts
T
Vinai Kopp f7f0504691 feat: add project versions (#110)
* refactor: allow version matrixes by projects

* feat: add initial version-matrix for mage-os

* feat: add project as optional input to action

* docs: document new input

* refactor: tighten types a bit

* chore: apply change requests from code review
2023-09-06 22:08:57 +02:00

22 lines
934 B
TypeScript

import { GithubActionsMatrix, PackageMatrixVersion } from "./matrix-type";
import { getIndividualVersionsForProject, getCompositeVersionsForProject } from "../versions/get-versions-for-project";
/**
* Computes the GitHub Actions Matrix for given versions of Magento
*/
export const getMatrixForVersions = (project: string, versions: string[]): GithubActionsMatrix => {
const knownVersions : Record<string, PackageMatrixVersion> = {
...getIndividualVersionsForProject(project), ...getCompositeVersionsForProject(project)
}
return versions.reduce((acc, current): GithubActionsMatrix => {
if (knownVersions[current] === undefined){
throw new Error(`Unknown "${current}" version while computing matrix`);
}
return {
magento: [...acc.magento, current],
include: [...acc.include, knownVersions[current]]
}
}, {magento: [], include: []});
}