diff --git a/.github/workflows/test-persistence.yml b/.github/workflows/test-persistence.yml index 60bed8856..2b64fd2e3 100644 --- a/.github/workflows/test-persistence.yml +++ b/.github/workflows/test-persistence.yml @@ -34,7 +34,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v1 with: - node-version: '14.x' + node-version: '18.x' - name: Install dependencies run: npm install --dev - name: Lint diff --git a/infrastructure/ecs-main/buckets.yml b/infrastructure/ecs-main/buckets.yml index 24fd72f7d..f4f7dfcea 100644 --- a/infrastructure/ecs-main/buckets.yml +++ b/infrastructure/ecs-main/buckets.yml @@ -78,6 +78,12 @@ Resources: Protocol: "https" HostName: ${self:custom.site.host.${self:provider.stage}} ReplaceKeyPrefixWith: ${self:custom.site.prefix.${self:provider.stage}}/atlas/cli/v1.1 + - RoutingRuleCondition: + KeyPrefixEquals: ${self:custom.site.prefix.${self:provider.stage}}/php-library/master + RedirectRule: + Protocol: "https" + HostName: ${self:custom.site.host.${self:provider.stage}} + ReplaceKeyPrefixWith: ${self:custom.site.prefix.${self:provider.stage}}/php-library/upcoming DocAtlasBucket: Type: "AWS::S3::Bucket" Properties: diff --git a/modules/persistence/.nvmrc b/modules/persistence/.nvmrc index 9f4189900..12ea1eebc 100644 --- a/modules/persistence/.nvmrc +++ b/modules/persistence/.nvmrc @@ -1 +1 @@ -v14.17.6 \ No newline at end of file +v18.12.0 \ No newline at end of file diff --git a/modules/persistence/src/services/metadata/ToC/index.ts b/modules/persistence/src/services/metadata/ToC/index.ts index 9f9e0fe61..580fb0beb 100644 --- a/modules/persistence/src/services/metadata/ToC/index.ts +++ b/modules/persistence/src/services/metadata/ToC/index.ts @@ -1,4 +1,3 @@ -import { AssociatedProduct, hasAssociations } from '../associated_products'; import { Metadata } from '..'; import { convertSlugToUrl } from './utils/convertSlugToUrl'; @@ -93,15 +92,19 @@ const mergeTocTreeOrder = (metadata: Metadata, node, insertions: TocOrderInserti // contains an associated_products entry export const traverseAndMerge = ( metadata: Metadata, - associated_products: AssociatedProduct[], + umbrellaMetadata: Metadata, umbrellaToCs: ToCCopies, tocInsertions: ToCInsertions, tocOrderInsertions: TocOrderInsertions ) => { const { project } = metadata; + const associatedProducts = umbrellaMetadata.associated_products || []; - const toctree = hasAssociations(metadata) ? umbrellaToCs.original : umbrellaToCs.urlified; - const toBeInserted = new Set(associated_products.map((p) => p.name)); + const associatedProductNames = associatedProducts.map((p) => p.name); + const toctree = structuredClone( + metadata.project === umbrellaMetadata.project ? umbrellaToCs.original : umbrellaToCs.urlified + ); + const toBeInserted = new Set(associatedProductNames); let queue = [toctree]; while (queue?.length && toBeInserted.size) { let next = queue.shift(); diff --git a/modules/persistence/src/services/metadata/associated_products/index.ts b/modules/persistence/src/services/metadata/associated_products/index.ts index 9ac5abf4e..c640da419 100644 --- a/modules/persistence/src/services/metadata/associated_products/index.ts +++ b/modules/persistence/src/services/metadata/associated_products/index.ts @@ -26,12 +26,6 @@ interface AggregatedMetadata { most_recent: Metadata; } -type EnvKeyedObject = { - prd: any; - preprd: any; - dotcomstg: any; - dotcomprd: any; -}; // TODO: move the branch/repobranch interfaces into their own file, or into a seperate abstraction? export interface BranchEntry { name: string; @@ -69,8 +63,8 @@ const umbrellaMetadataEntry = async (project: string): Promise => { return null as unknown as Metadata; } - const repoDoc = await getRepoBranchesEntry(project); - const branchNames = repoDoc.branches.map((branchEntry) => branchEntry.gitBranchName); + const umbrellaRepos = await getRepoBranchesEntry(umbrella.project); + const branchNames = umbrellaRepos.branches.map((branchEntry) => branchEntry.gitBranchName); const entry = await snooty .collection('metadata') .find({ @@ -198,7 +192,7 @@ export const mergeAssociatedToCs = async (metadata: Metadata) => { const mergedMetadataEntries = [umbrellaMetadata, ...associatedMetadataEntries].map((metadataEntry) => { const mergedMetadataEntry = traverseAndMerge( metadataEntry, - umbrellaMetadata.associated_products || [], + umbrellaMetadata, umbrellaToCs, tocInsertions, tocOrderInsertions diff --git a/modules/persistence/src/services/metadata/repos_branches/index.ts b/modules/persistence/src/services/metadata/repos_branches/index.ts index cfdd37016..ab1af6c20 100644 --- a/modules/persistence/src/services/metadata/repos_branches/index.ts +++ b/modules/persistence/src/services/metadata/repos_branches/index.ts @@ -65,6 +65,11 @@ const getAggregationPipeline = (matchCondition: any) => { repo: 0, }, }, + { + $sort: { + prodDeployable: -1, + }, + }, ]; }; diff --git a/modules/persistence/tests/metadata/ToC.test.ts b/modules/persistence/tests/metadata/ToC.test.ts index 684282a97..ff8ed23ee 100644 --- a/modules/persistence/tests/metadata/ToC.test.ts +++ b/modules/persistence/tests/metadata/ToC.test.ts @@ -122,7 +122,7 @@ describe('ToC module', () => { expect( traverseAndMerge( umbrellaMetadata as unknown as Metadata, - umbrellaMetadata.associated_products || [], + umbrellaMetadata, umbrellaToCs, tocInsertions, tocOrderInsertions @@ -135,7 +135,7 @@ describe('ToC module', () => { expect( traverseAndMerge( metadata[0] as unknown as Metadata, - umbrellaMetadata.associated_products || [], + umbrellaMetadata, umbrellaToCs, tocInsertions, tocOrderInsertions diff --git a/modules/persistence/tests/setupAfterEnv.ts b/modules/persistence/tests/setupAfterEnv.ts index 061a85eaf..2b73fc367 100644 --- a/modules/persistence/tests/setupAfterEnv.ts +++ b/modules/persistence/tests/setupAfterEnv.ts @@ -1,4 +1,5 @@ beforeAll(() => { // Disable console.time from crowding test output console.time = jest.fn(); + global.structuredClone = (val) => JSON.parse(JSON.stringify(val)); });