Skip to content

Commit 156ed81

Browse files
authored
Rename @guardian/commercial -> @guardian/commercial-core (#2095)
1 parent b5c8c1d commit 156ed81

81 files changed

Lines changed: 219 additions & 216 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/every-feet-bow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
'@guardian/commercial': minor
2+
'@guardian/commercial-core': minor
33
---
44

55
Export all modules in the package

.changeset/funny-ghosts-go.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
'@guardian/commercial': minor
2+
'@guardian/commercial-core': minor
33
---
44

55
More isolation from the commercial bundle

.changeset/tame-jars-wish.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@guardian/commercial-core': major
3+
---
4+
5+
Package renamed

.github/workflows/beta-release-on-label.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
has-permission:
1414
name: Check permissions
1515
runs-on: ubuntu-latest
16-
if: github.event.label.name == '[beta] @guardian/commercial'
16+
if: github.event.label.name == '[beta] @guardian/commercial-core'
1717
steps:
1818
- name: Check if organization member
1919
id: is_organization_member
@@ -24,10 +24,10 @@ jobs:
2424
token: ${{ secrets.GITHUB_TOKEN }}
2525

2626
release:
27-
name: '@guardian/commercial'
27+
name: '@guardian/commercial-core'
2828
runs-on: ubuntu-latest
2929
needs: has-permission
30-
if: github.event.label.name == '[beta] @guardian/commercial'
30+
if: github.event.label.name == '[beta] @guardian/commercial-core'
3131
steps:
3232
- name: Checkout
3333
uses: actions/checkout@v4.2.2
@@ -73,9 +73,9 @@ jobs:
7373
7474
To install the beta version, run one of the following commands in your project directory:
7575
\`\`\`
76-
npm install @guardian/commercial@${version}
77-
pnpm add @guardian/commercial@${version}
78-
yarn add @guardian/commercial@${version}
76+
npm install @guardian/commercial-core@${version}
77+
pnpm add @guardian/commercial-core@${version}
78+
yarn add @guardian/commercial-core@${version}
7979
\`\`\`
8080
`
8181
})
@@ -90,5 +90,5 @@ jobs:
9090
issue_number: context.issue.number,
9191
owner: context.repo.owner,
9292
repo: context.repo.repo,
93-
name: '[beta] @guardian/commercial'
93+
name: '[beta] @guardian/commercial-core'
9494
})

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
id: changesets
128128
uses: changesets/action@v1.5.3
129129
with:
130-
publish: pnpm --filter @guardian/commercial changeset publish
130+
publish: pnpm --filter @guardian/commercial-core changeset publish
131131
title: '🦋 Release package updates'
132132
commit: 'Bump package versions'
133133
setupGitUser: false

README.md

Lines changed: 10 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,29 @@
11
# Commercial Monorepo
22

3-
This package contains the code for the commercial bundle that is loaded on all pages on theguardian.com.
3+
This package contains the commercial (advertising) code that is loaded on all pages on theguardian.com.
44

5-
There are 2 main parts to this repo:
6-
- The commercial bundle itself, which is a set of javascript files that is loaded on all pages on theguardian.com.
7-
- Some modules that are used by other parts of the Guardian codebase, such as DCR. This is published as a package to npm, `@guardian/commercial`.
8-
9-
The `@guardian/commercial` modules are in `core/src`, everything else is only part of the commercial bundle and not the `@guardian/commercial` package.
5+
There are 2 packages in this repo:
6+
- [`@guardian/commercial-bundle`](./bundle/) The commercial bundle, which is an independent set of javascript files that is loaded on all pages on theguardian.com.
7+
- [`@guardian/commercial-core`](./core/) An npm package used by other parts of the Guardian codebase, such as DCR.
108

119
## Development
1210

13-
**For working on the commercial bundle, see below. For working on the `@guardian/commercial` npm package, see [core/README.md](core/README.md).**
14-
1511
### Requirements
1612

1713
- Node
18-
- see [.nvmrc](../.nvmrc) for the current version
14+
- see [.nvmrc](./.nvmrc) for the current version
1915
- the version manager [fnm](https://github.com/Schniz/fnm) is recommended with additional configuration to automatically switch on [changing directory](https://github.com/Schniz/fnm#shell-setup)
2016
- pnpm
2117

2218
### Setup
2319

2420
To install dependencies, run `pnpm`.
2521

26-
To develop the bundle locally on the bundle, run `pnpm serve` to start a local server. This will watch for changes and rebuild the bundle. Serving it at `http://localhost:3031`.
27-
28-
### Pull requests
29-
30-
Try to write PR titles in the conventional commit format, and squash and merge when merging. That way your PR will trigger a release when you merge it (if necessary).
31-
32-
### Working locally with DCR
33-
34-
1. To point DCR to the local commercial bundle, in the `dotcom-rendering/dotcom-rendering` directory run:
35-
36-
`COMMERCIAL_BUNDLE_URL=http://localhost:3031/graun.standalone.commercial.js PORT=3030 make dev`
37-
38-
This will override `commercialBundleUrl` passed via the page config from PROD/CODE.
39-
40-
1. In another terminal start the commercial dev server to serve the local bundle:
41-
42-
`pnpm serve`
43-
44-
### Testing locally with DCR
45-
46-
To run the unit tests:
47-
48-
`pnpm test`
49-
50-
To run the Playwright e2e tests:
51-
52-
Follow the steps above to run DCR against the local bundle.
53-
54-
`pnpm playwright:run` will run the tests on the command line
55-
56-
`pnpm playwright:open` will open the Playwright UI so you can inspect the tests as they run
57-
58-
### Working locally with Frontend
59-
60-
To use the bundle locally with Frontend, you can override your default Frontend configuration ([see the Frontend docs for more detail on this](https://github.com/guardian/frontend/blob/038406bb5f876afd139b4747711c76551e8a7add/docs/03-dev-howtos/14-override-default-configuration.md)) to point to a local commercial dev server. For example, save the following in `~/.gu/frontend.conf`:
61-
62-
```
63-
devOverrides {
64-
commercial.overrideCommercialBundleUrl="http://localhost:3031/graun.standalone.commercial.js"
65-
}
66-
```
67-
68-
Frontend will then use the local bundle instead of the one from PROD/CODE. Frontend will pass the local bundle URL along to DCR, so you don't have to override there if you've done it in Frontend.
69-
70-
### Linking
71-
72-
To use the production bundle locally with Frontend, run `pnpm link` in the bundle directory. Then run `yarn link @guardian/commercial` in the frontend directory. Finally, start the frontend server as usual.
73-
74-
Frontend will then use the local bundle instead of the one from PROD/CODE.
75-
76-
### Testing on CODE
77-
78-
To test the bundle on CODE, create a PR, wait for github actions to run and a riff-raff comment should appear. Click the link in the comment to confirm the CODE deployment.
79-
80-
Although you can deploy CODE changes without deploying Frontend or DCR, it's a good idea to flag any CODE deployments on the dotcom semaphore chat in case it has an effect on anything anyone else is testing.
81-
22+
### A Note on Deployments
23+
[`@guardian/commercial-bundle`](./bundle/) and [`@guardian/commercial-core`](./core/) are deployed separately.
8224

83-
### Deploying to PROD
25+
`@guardian/commercial-bundle` is deployed to PROD automatically when merged to main. It does not use changesets.
8426

85-
When you merge to main the commercial bundle will be deployed automatically and should be live within a few minutes.
27+
`@guardian/commercial-core` is published as an npm package and uses changesets, if you've made changes to this package, you will need to ensure you have added a changeset before merging your PR.
8628

87-
[More details on deployment](docs/deployment/readme.md)
29+
A `commercial-dev` team member will then need to merge the changeset PR to release the new version.

bundle/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Commercial Bundle
2+
This package contains the commercial (advertising) code that is loaded on all pages on theguardian.com.
3+
4+
## Development
5+
To develop the bundle locally on the bundle, run `pnpm serve` to start a local server. This will watch for changes and rebuild the bundle. Serving it at `http://localhost:3031`.
6+
7+
### Working locally with DCR
8+
9+
1. To point DCR to the local commercial bundle, in the `dotcom-rendering/dotcom-rendering` directory run:
10+
11+
`COMMERCIAL_BUNDLE_URL=http://localhost:3031/graun.standalone.commercial.js PORT=3030 make dev`
12+
13+
This will override `commercialBundleUrl` passed via the page config from PROD/CODE.
14+
15+
1. In another terminal start the commercial dev server to serve the local bundle:
16+
17+
`pnpm serve`
18+
19+
### Testing locally with DCR
20+
21+
To run the unit tests:
22+
23+
`pnpm test`
24+
25+
To run the Playwright e2e tests:
26+
27+
Follow the steps above to run DCR against the local bundle.
28+
29+
`pnpm playwright:run` will run the tests on the command line
30+
31+
`pnpm playwright:open` will open the Playwright UI so you can inspect the tests as they run
32+
33+
### Working locally with Frontend
34+
35+
To use the bundle locally with Frontend, you can override your default Frontend configuration ([see the Frontend docs for more detail on this](https://github.com/guardian/frontend/blob/038406bb5f876afd139b4747711c76551e8a7add/docs/03-dev-howtos/14-override-default-configuration.md)) to point to a local commercial dev server. For example, save the following in `~/.gu/frontend.conf`:
36+
37+
```
38+
devOverrides {
39+
commercial.overrideCommercialBundleUrl="http://localhost:3031/graun.standalone.commercial.js"
40+
}
41+
```
42+
43+
Frontend will then use the local bundle instead of the one from PROD/CODE. Frontend will pass the local bundle URL along to DCR, so you don't have to override there if you've done it in Frontend.
44+
45+
### Testing on CODE
46+
47+
To test the bundle on CODE, create a PR, wait for github actions to run and a riff-raff comment should appear. Click the link in the comment to confirm the CODE deployment.
48+
49+
Although you can deploy CODE changes without deploying Frontend or DCR, it's a good idea to flag any CODE deployments on the dotcom semaphore chat in case it has an effect on anything anyone else is testing.
50+
51+
52+
### Deploying to PROD
53+
54+
When you merge to main the commercial bundle will be deployed automatically and should be live within a few minutes.
55+
56+
[More details on deployment](docs/deployment/readme.md)

bundle/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"dependencies": {
3636
"@guardian/ab-core": "catalog:",
3737
"@guardian/core-web-vitals": "11.0.0",
38-
"@guardian/commercial": "workspace:*",
38+
"@guardian/commercial-core": "workspace:*",
3939
"@guardian/identity-auth": "^7.0.0",
4040
"@guardian/identity-auth-frontend": "9.0.0",
4141
"@guardian/libs": "catalog:",

bundle/src/define/Advert.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type * as AdSizesType from '@guardian/commercial/ad-sizes';
2-
import { slotSizeMappings as slotSizeMappings_ } from '@guardian/commercial/ad-sizes';
1+
import type * as AdSizesType from '@guardian/commercial-core/ad-sizes';
2+
import { slotSizeMappings as slotSizeMappings_ } from '@guardian/commercial-core/ad-sizes';
33
import { _, Advert, findSmallestAdHeightForSlot } from './Advert';
44

55
const { getSlotSizeMapping } = _;
@@ -8,9 +8,9 @@ jest.mock('define/init-slot-ias', () => ({
88
initSlotIas: jest.fn(() => Promise.resolve()),
99
}));
1010

11-
jest.mock('@guardian/commercial/ad-sizes', () => {
11+
jest.mock('@guardian/commercial-core/ad-sizes', () => {
1212
const adSizes: typeof AdSizesType = jest.requireActual(
13-
'@guardian/commercial/ad-sizes',
13+
'@guardian/commercial-core/ad-sizes',
1414
);
1515
const slotSizeMappings = adSizes.slotSizeMappings;
1616
const slots = {
@@ -40,7 +40,7 @@ jest.mock('@guardian/commercial/ad-sizes', () => {
4040
};
4141
});
4242

43-
jest.mock('@guardian/commercial/targeting/teads-eligibility', () => ({
43+
jest.mock('@guardian/commercial-core/targeting/teads-eligibility', () => ({
4444
isEligibleForTeads: jest.fn(),
4545
}));
4646

bundle/src/define/Advert.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import {
22
createAdSize,
33
findAppliedSizesForBreakpoint,
44
slotSizeMappings,
5-
} from '@guardian/commercial/ad-sizes';
5+
} from '@guardian/commercial-core/ad-sizes';
66
import type {
77
AdSize,
88
SizeMapping,
99
SlotName,
10-
} from '@guardian/commercial/ad-sizes';
11-
import type { Breakpoint } from '@guardian/commercial/breakpoint';
12-
import type { Advert as IAdvert } from '@guardian/commercial/types';
10+
} from '@guardian/commercial-core/ad-sizes';
11+
import type { Breakpoint } from '@guardian/commercial-core/breakpoint';
12+
import type { Advert as IAdvert } from '@guardian/commercial-core/types';
1313
import { breakpoints as sourceBreakpoints } from '@guardian/source/foundations';
1414
import { concatSizeMappings } from '../lib/create-ad-slot';
1515
import fastdom from '../lib/fastdom-promise';

0 commit comments

Comments
 (0)