Skip to content

Commit a43c3af

Browse files
committed
Merge branch 'main' into add-gallery-lightbox
2 parents 25de439 + 4f49bd2 commit a43c3af

File tree

3 files changed

+130
-30
lines changed

3 files changed

+130
-30
lines changed

dotcom-rendering/scripts/check-node-versions.mjs

Lines changed: 79 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { readFile } from 'node:fs/promises';
44
import { dirname, resolve } from 'node:path';
55
import { fileURLToPath } from 'node:url';
66
import { log, warn } from '../../scripts/log.js';
7+
import semverParse from 'semver/functions/parse.js';
8+
import semverSatisfies from 'semver/functions/satisfies.js';
79

810
const __dirname = dirname(fileURLToPath(import.meta.url));
911

@@ -27,36 +29,101 @@ if (!nodeVersion) {
2729
log(`Found node version ${nodeVersion} in \`.nvmrc\``);
2830
}
2931

32+
/**
33+
* @typedef {'major' | 'minor' | 'patch'} MatchLevel
34+
*/
3035
const requiredNodeVersionMatches =
31-
/** @type {const} @satisfies {ReadonlyArray<{filepath: string, pattern: RegExp}>}*/ ([
36+
/** @type {const} @satisfies {ReadonlyArray<{filepath: string, pattern: RegExp, matchLevel: MatchLevel}>}*/ ([
3237
{
3338
filepath: 'Containerfile',
3439
pattern: /^FROM node:(.+)-alpine$/m,
40+
matchLevel: 'patch',
3541
},
3642
{
3743
filepath: 'scripts/deploy/riff-raff.yaml',
3844
pattern: /^ +Recipe: dotcom-rendering.*-node-(\d+\.\d+\.\d+).*?$/m,
45+
matchLevel: 'patch',
3946
},
4047
{
4148
filepath: '../apps-rendering/riff-raff.yaml',
4249
pattern: /^ +Recipe: apps-rendering.*-node-(\d+\.\d+\.\d+).*?$/m,
50+
matchLevel: 'patch',
51+
},
52+
{
53+
filepath: 'package.json',
54+
pattern: /^\t+"@types\/node"\: "(.+)",$/m,
55+
/*
56+
Definitely Typed packages only match the major and minor
57+
versions of the corresponding library/node release.
58+
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#how-do-definitely-typed-package-versions-relate-to-versions-of-the-corresponding-library
59+
60+
Note: Given this rule, this should be set to 'minor'. It's currently
61+
set to 'major' because the latest node release doesn't yet have
62+
types available for it (v22.18.0, latest types package is v22.17.x).
63+
*/
64+
matchLevel: 'major',
65+
},
66+
{
67+
filepath: '../apps-rendering/package.json',
68+
pattern: /^\t+"@types\/node"\: "(.+)",$/m,
69+
/*
70+
Definitely Typed packages only match the major and minor
71+
versions of the corresponding library/node release.
72+
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#how-do-definitely-typed-package-versions-relate-to-versions-of-the-corresponding-library
73+
74+
Note: Given this rule, this should be set to 'minor'. It's currently
75+
set to 'major' because the latest node release doesn't yet have
76+
types available for it (v22.18.0, latest types package is v22.17.x).
77+
*/
78+
matchLevel: 'major',
4379
},
4480
]);
4581

82+
/**
83+
*
84+
* @param {string} a
85+
* @param {string} b
86+
* @param {MatchLevel} matchLevel
87+
* @returns boolean
88+
*/
89+
const versionMatches = (a, b, matchLevel) => {
90+
const semverA = semverParse(a);
91+
92+
switch (matchLevel) {
93+
case 'major':
94+
return semverSatisfies(b, `${semverA?.major}.x.x`);
95+
case 'minor':
96+
return semverSatisfies(b, `${semverA?.major}.${semverA?.minor}.x`);
97+
case 'patch':
98+
return semverSatisfies(b, a);
99+
}
100+
};
101+
46102
const problems = (
47103
await Promise.all(
48-
requiredNodeVersionMatches.map(async ({ filepath, pattern }) => {
49-
const fileContents = await readFile(
50-
resolve(...filepath.split('/')),
51-
'utf-8',
52-
);
53-
const foundNodeVersion =
54-
fileContents.match(pattern)?.[1] ?? undefined;
104+
requiredNodeVersionMatches.map(
105+
async ({ filepath, pattern, matchLevel }) => {
106+
const fileContents = await readFile(
107+
resolve(...filepath.split('/')),
108+
'utf-8',
109+
);
110+
const foundNodeVersion =
111+
fileContents.match(pattern)?.[1] ?? undefined;
112+
113+
const matches =
114+
foundNodeVersion === undefined
115+
? false
116+
: versionMatches(
117+
nodeVersion,
118+
foundNodeVersion,
119+
matchLevel,
120+
);
55121

56-
return foundNodeVersion === nodeVersion
57-
? undefined
58-
: `Node version in ${filepath} (${foundNodeVersion}) does not match \`.nvmrc\` (${nodeVersion})`;
59-
}),
122+
return matches
123+
? undefined
124+
: `Node version in ${filepath} (${foundNodeVersion}) does not match \`.nvmrc\` (${nodeVersion}), expected them to match versions to the ${matchLevel} level`;
125+
},
126+
),
60127
)
61128
).filter(
62129
/** @type {(problem?: string) => problem is string} */

dotcom-rendering/src/components/TextBlockComponent.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ export const textBlockStyles = (format: ArticleFormat) => css`
187187
li {
188188
margin-bottom: ${remSpace[1]};
189189
padding-left: ${remSpace[5]};
190-
display: flow-root;
191190
192191
p {
193192
margin: -1.5rem 0 0 0;

dotcom-rendering/src/layouts/GalleryLayout.tsx

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@ import { MainMediaGallery } from '../components/MainMediaGallery';
2323
import { Masthead } from '../components/Masthead/Masthead';
2424
import { Section } from '../components/Section';
2525
import { Standfirst } from '../components/Standfirst';
26+
import { StickyBottomBanner } from '../components/StickyBottomBanner.importable';
2627
import { SubMeta } from '../components/SubMeta';
2728
import { grid } from '../grid';
2829
import { type ArticleFormat, ArticleSpecial } from '../lib/articleFormat';
2930
import { canRenderAds } from '../lib/canRenderAds';
31+
import { getContributionsServiceUrl } from '../lib/contributions';
3032
import { decideMainMediaCaption } from '../lib/decide-caption';
3133
import { getAdPositions } from '../lib/getGalleryAdPositions';
3234
import type { NavType } from '../model/extract-nav';
3335
import { palette as themePalette } from '../palette';
3436
import type { Gallery } from '../types/article';
3537
import type { RenderingTarget } from '../types/renderingTarget';
36-
import { Stuck } from './lib/stickiness';
38+
import { BannerWrapper, Stuck } from './lib/stickiness';
3739

3840
interface Props {
3941
gallery: Gallery;
@@ -155,6 +157,8 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
155157

156158
const renderAds = canRenderAds(frontendData);
157159

160+
const contributionsServiceUrl = getContributionsServiceUrl(frontendData);
161+
158162
const adPositions: number[] = renderAds
159163
? getAdPositions(gallery.images)
160164
: [];
@@ -367,22 +371,52 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
367371
</Section>
368372
)}
369373
{isWeb && (
370-
<Section
371-
fullWidth={true}
372-
padSides={false}
373-
backgroundColour={sourcePalette.brand[400]}
374-
borderColour={sourcePalette.brand[600]}
375-
showSideBorders={false}
376-
element="footer"
377-
>
378-
<Footer
379-
pageFooter={frontendData.pageFooter}
380-
selectedPillar={props.NAV.selectedPillar}
381-
pillars={props.NAV.pillars}
382-
urls={frontendData.nav.readerRevenueLinks.footer}
383-
editionId={frontendData.editionId}
384-
/>
385-
</Section>
374+
<>
375+
<Section
376+
fullWidth={true}
377+
padSides={false}
378+
backgroundColour={sourcePalette.brand[400]}
379+
borderColour={sourcePalette.brand[600]}
380+
showSideBorders={false}
381+
element="footer"
382+
>
383+
<Footer
384+
pageFooter={frontendData.pageFooter}
385+
selectedPillar={props.NAV.selectedPillar}
386+
pillars={props.NAV.pillars}
387+
urls={frontendData.nav.readerRevenueLinks.footer}
388+
editionId={frontendData.editionId}
389+
/>
390+
</Section>
391+
<BannerWrapper data-print-layout="hide">
392+
<Island priority="feature" defer={{ until: 'idle' }}>
393+
<StickyBottomBanner
394+
contentType={frontendData.contentType}
395+
contributionsServiceUrl={
396+
contributionsServiceUrl
397+
}
398+
idApiUrl={frontendData.config.idApiUrl}
399+
isMinuteArticle={
400+
frontendData.pageType.isMinuteArticle
401+
}
402+
isPaidContent={
403+
frontendData.pageType.isPaidContent
404+
}
405+
isPreview={!!frontendData.config.isPreview}
406+
isSensitive={frontendData.config.isSensitive}
407+
pageId={frontendData.pageId}
408+
sectionId={frontendData.config.section}
409+
shouldHideReaderRevenue={
410+
frontendData.shouldHideReaderRevenue
411+
}
412+
remoteBannerSwitch={
413+
!!frontendData.config.switches.remoteBanner
414+
}
415+
tags={frontendData.tags}
416+
/>
417+
</Island>
418+
</BannerWrapper>
419+
</>
386420
)}
387421
{isApps && (
388422
<div

0 commit comments

Comments
 (0)