-
Notifications
You must be signed in to change notification settings - Fork 15
Feat: Add support for additional metapackages (closes #238) #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Remembered an issue I need to address before finalizing: I have not yet tested historical builds of alternate metapackage releases. I suspect changes will be needed for the transform changes to be locked in place for historical releases, and not reapplied from the transform against past releases. We don't want v3 removing additional packages to also remove those from v2. |
…ady have it in full
|
Handled. New 'minimal' example transforms: {
name: 'project-minimal',
type: 'project',
fromTag: '2.1.0',
description: 'Mage-OS Minimal Edition Project',
transform: [
transformMagentoCommunityEditionProject,
transformMageOSCommunityEditionProject,
]
},
{
name: 'product-minimal',
type: 'metapackage',
fromTag: '2.1.0',
description: 'Mage-OS Minimal Edition',
transform: [
transformMagentoCommunityEditionProduct,
transformMageOSCommunityEditionProduct,
/**
* @param {{}} composerConfig
* @param {repositoryBuildDefinition} instruction
* @param {metapackageDefinition} metapackage
* @param {buildState} release
*/
async (composerConfig, instruction, metapackage, release) => {
if (composerConfig.version !== release.version) {
return composerConfig;
}
// Mock removing inventory and graphql packages for minimal edition
for (const pkg of Object.keys(composerConfig.require)) {
if (pkg.includes('-graph-ql') || pkg.includes('-inventory') || pkg.includes('-media')) {
delete composerConfig.require[pkg];
}
}
return composerConfig;
}
]
}Added code to the metapackage builders to allow us to store the entire built JSON in the repo, instead of just the composer template values for the version, to account for any transform differences in effect as well. It is necessary to create new It is necessary to commit the entire composer project and product JSON files for the history for these deviating metapackages. We have to track the full state to keep a reliable history. Long-term, we could perhaps simplify by making release creation and repo/mirror building two separate things, where the new-version build tags and PRs the various files and updates involved, and the repo/mirror build purely creates files based on version histories and tags. But it's probably not worth the effort any time soon. As it stands, I think this is ready. |
Resolves #238
Overview
Substantial refactor replacing hardcoded metapackage flags with flexible configuration system.
Key Changes
Configuration Architecture
magentoCommunityEditionProjectandmagentoCommunityEditionMetapackagefromrepositoryBuildDefinitionextraMetapackagesarray accepting metapackage definitions with:name,type(project/metapackage),descriptionfromTag(optional starting version)transform[](array of transformation functions)Refactored Methods
Eliminated specialized functions:
createMagentoCommunityEditionMetapackage()createMagentoCommunityEditionProject()createProjectPackagesSinceTag()createMagentoCommunityEditionMetapackagesSinceTag()Replaced with generic
createMetaPackagesSinceTag()that iteratesextraMetapackages[]Transform Functions
New dedicated modules for composition-based transforms:
src/build-metapackage/magento-community-edition.jstransformMagentoCommunityEditionProject()transformMagentoCommunityEditionProduct()src/build-metapackage/mage-os-community-edition.jstransformMageOSCommunityEditionProject()transformMageOSCommunityEditionProduct()Transforms now async, called sequentially:
for (const fn of metapackage.transform) { composerConfig = await fn(...); }Configuration Examples
packages-config.js (Magento):
mageos-release-build-config.js (Mage-OS - chained transforms):
Context Propagation
releaseContext(buildState withcomposerRepoUrl) now passed toprocessMirrorInstruction()and downstreamsetMageosPackageRepoUrl()in favor of explicit contextHistorical Data
Added
magento_versionto Mage-OS product metapackage history files for upstream reference tracking.Benefits
createMetaPackagesSinceTag()handles all metapackagesAdditional notes
Build issues
In the process of refactoring and testing, I found some issues with the prior build setup that this fixes.
projectpackages weren't being given the proper separate description to match upstreammagento/magento2-baserequirement version tonull; it now properly matches the release versionmagento_versionin theproductcomposer.json for reference info, but historical Mage-OS versions have not, meaning each new release removed the info from the prior one. That'll no longer be the case. I added it to the release history file, and set it to copyextradata in too if present.Adding metapackages
The ultimate point of this was to be able to add more metapackages to the Mage-OS release process, as situations may warrant.
At least for now, I opted to do it via transform functions, rather than some system of include or exclude or add lists.
This is limited to changes to project and product composer files. If we want different code for one versus another, it would require a separate fork or bigger changes where packages are actually built.
I tested with these added metapackages, purely for demonstration: