Skip to content

Commit 34ccaab

Browse files
authored
Merge 473b0b4 into 7b8b9a6
2 parents 7b8b9a6 + 473b0b4 commit 34ccaab

129 files changed

Lines changed: 1155 additions & 595 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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@guardian/commercial': minor
3+
---
4+
5+
Test changeset

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
uses: ./.github/actions/setup-node-env
3939

4040
- name: Build package
41-
run: pnpm build
41+
run: pnpm build:core
4242

4343
- name: Version
4444
run: pnpm changeset version --snapshot beta

.github/workflows/ci.yml

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ jobs:
5252
- name: Check types
5353
run: pnpm tsc
5454

55-
build:
56-
name: Build
55+
build-bundle:
56+
name: Build Bundle
5757
runs-on: ubuntu-latest
5858
steps:
5959
- name: Checkout repo
@@ -63,17 +63,36 @@ jobs:
6363
uses: ./.github/actions/setup-node-env
6464

6565
- name: Build package
66-
run: pnpm build
66+
run: pnpm build:bundle
6767

6868
- name: Save build
6969
uses: actions/upload-artifact@v4.6.2
7070
with:
71-
name: dist
71+
name: bundle-dist
7272
path: dist
7373

74-
release:
75-
name: Release
76-
needs: [build, test, lint, types]
74+
build-core:
75+
name: Build Core
76+
runs-on: ubuntu-latest
77+
steps:
78+
- name: Checkout repo
79+
uses: actions/checkout@v4.2.2
80+
81+
- name: Set up Node
82+
uses: ./.github/actions/setup-node-env
83+
84+
- name: Build package
85+
run: pnpm build:core
86+
87+
- name: Save build
88+
uses: actions/upload-artifact@v4.6.2
89+
with:
90+
name: core-dist
91+
path: dist
92+
93+
changesets:
94+
name: Core Changesets
95+
needs: [build-core, test, lint, types]
7796
if: github.ref == 'refs/heads/main'
7897
runs-on: ubuntu-latest
7998
steps:
@@ -89,8 +108,8 @@ jobs:
89108
- name: Fetch build
90109
uses: actions/download-artifact@v4.3.0
91110
with:
92-
name: dist
93-
path: dist
111+
name: core-dist
112+
path: core/dist
94113

95114
- name: Use GitHub App Token
96115
uses: actions/create-github-app-token@v2
@@ -108,7 +127,7 @@ jobs:
108127
id: changesets
109128
uses: changesets/action@v1.5.3
110129
with:
111-
publish: pnpm changeset publish
130+
publish: pnpm --filter @guardian/commercial changeset publish
112131
title: '🦋 Release package updates'
113132
commit: 'Bump package versions'
114133
setupGitUser: false
@@ -117,8 +136,8 @@ jobs:
117136
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
118137

119138
riff-raff:
120-
name: Upload Riff Raff Artifacts
121-
needs: [build, test, lint, types]
139+
name: Upload Bundle Riff Raff Artifacts
140+
needs: [build-bundle, test, lint, types]
122141
runs-on: ubuntu-latest
123142
permissions:
124143
id-token: write
@@ -138,7 +157,7 @@ jobs:
138157
- name: Fetch build
139158
uses: actions/download-artifact@v4.3.0
140159
with:
141-
name: dist
160+
name: bundle-dist
142161
path: dist
143162

144163
- name: Riff-Raff Upload

.github/workflows/compressed-size-action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: preactjs/compressed-size-action@v2
2222
with:
2323
repo-token: ${{secrets.GITHUB_TOKEN}}
24-
build-script: build:prod
24+
build-script: build:bundle
2525
# having a higher change threshold makes the reporting a little less sensitive and more reliable
2626
minimum-change-threshold: 50
2727
# filenames are hashed so we need to strip that, or it thinks we've created new files every build

README.md

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
# @guardian/commercial
1+
# Commercial Monorepo
22

33
This package contains the code for the commercial bundle that is loaded on all pages on theguardian.com.
44

55
There are 2 main parts to this repo:
66
- The commercial bundle itself, which is a set of javascript files that is loaded on all pages on theguardian.com.
77
- 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`.
88

9-
The exported modules are in `src/core`, everything else is part of the commercial bundle.
10-
11-
## Installation
12-
13-
To install the npm package, run `pnpm i @guardian/commercial`.
9+
The `@guardian/commercial` modules are in `core/src`, everything else is only part of the commercial bundle and not the `@guardian/commercial` package.
1410

1511
## Development
1612

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+
1715
### Requirements
1816

1917
- Node
@@ -25,15 +23,7 @@ To install the npm package, run `pnpm i @guardian/commercial`.
2523

2624
To install dependencies, run `pnpm`.
2725

28-
To develop 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`.
29-
30-
### Releasing to NPM
31-
32-
This repository uses [changesets](https://github.com/changesets/changesets) for version management
33-
34-
To release a new version with your changes, run `pnpm changeset add` and follow the prompts. This will create a new changeset file in the `.changeset` directory. Commit this file with your PR.
35-
36-
When your PR is merged, changeset will analyse the changes and create a PR to release the new version.
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`.
3727

3828
### Pull requests
3929

@@ -89,12 +79,6 @@ To test the bundle on CODE, create a PR, wait for github actions to run and a ri
8979

9080
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.
9181

92-
#### Testing changes to the `@guardian/commercial` npm package
93-
You can add the [beta] @guardian/commercial label to your pull request, this will release a beta version of the bundle to NPM, the exact version will be commented on your PR.
94-
95-
In order to do this, run `pnpm changeset`. This will create a new changeset file in the .changeset directory. Commit this file with your PR.
96-
97-
Note: Once the beta version is released, the label will be removed from the PR, so you will need to add it again if you want to release subsequent new versions.
9882

9983
### Deploying to PROD
10084

core/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# @guardian/commercial
2+
3+
This directory contains the modules that are published as the `@guardian/commercial` npm package.
4+
5+
## Installation
6+
7+
To install the npm package, install with your favourite package manager:
8+
9+
```bash
10+
pnpm i @guardian/commercial
11+
yarn add @guardian/commercial
12+
npm i @guardian/commercial
13+
```
14+
15+
## Development
16+
17+
build the package with:
18+
19+
```bash
20+
pnpm build
21+
```
22+
23+
This will build the package into the `dist` directory, which is what is published to npm.
24+
25+
#### Testing changes to the `@guardian/commercial` npm package
26+
You can add the [beta] @guardian/commercial label to your pull request, this will release a beta version of the bundle to NPM, the exact version will be commented on your PR.
27+
28+
In order to do this, run `pnpm changeset`. This will create a new changeset file in the .changeset directory. Commit this file with your PR.
29+
30+
Note: Once the beta version is released, the label will be removed from the PR, so you will need to add it again if you want to release subsequent new versions.
31+
32+
## Releasing to NPM
33+
This repository uses changesets for version management.
34+
35+
To release a new version with your changes, run:
36+
37+
```bash
38+
pnpm changeset add
39+
```
40+
41+
and follow the prompts. This will create a new changeset file in the `.changeset` directory. Commit this file with your PR.
42+
43+
When your PR is merged, changeset will analyse the changes and create a PR to release the new version.
44+
45+
if you are part of the `commercial` team, you can merge the changeset PR to release the new version. If you are not part of the `commercial` team, you will need to ask someone who is to merge the PR for you.

core/package.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "@guardian/commercial",
3+
"version": "26.0.0",
4+
"description": "Guardian advertising business logic",
5+
"homepage": "https://github.com/guardian/commercial#readme",
6+
"bugs": {
7+
"url": "https://github.com/guardian/commercial/issues"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/guardian/commercial.git"
12+
},
13+
"license": "Apache-2.0",
14+
"files": [
15+
"dist"
16+
],
17+
"main": "dist/cjs/index.js",
18+
"module": "dist/esm/index.js",
19+
"exports": {
20+
".": {
21+
"import": "./dist/esm/index.js",
22+
"require": "./dist/cjs/index.js",
23+
"workspace": "./src/index.ts"
24+
},
25+
"./*": {
26+
"import": "./dist/esm/*.js",
27+
"require": "./dist/cjs/*.js",
28+
"workspace": "./src/*.ts"
29+
},
30+
"./package.json": "./package.json"
31+
},
32+
"scripts": {
33+
"build": "npm-run-all clean --parallel build:core:*",
34+
"clean": "rm -rf dist",
35+
"build:core:esm": "tsc --outDir ./dist/esm --project ./tsconfig.esm.json",
36+
"build:core:cjs": "tsc --outDir ./dist/cjs --project ./tsconfig.cjs.json",
37+
"tsc": "tsc --noEmit"
38+
},
39+
"peerDependencies": {
40+
"@guardian/ab-core": "catalog:",
41+
"@guardian/libs": "catalog:"
42+
},
43+
"dependencies": {
44+
"@guardian/ab-core": "catalog:",
45+
"@guardian/libs": "catalog:"
46+
},
47+
"devDependencies": {
48+
"@types/node": "catalog:",
49+
"typescript": "catalog:"
50+
},
51+
"publishConfig": {
52+
"access": "public"
53+
},
54+
"packageManager": "pnpm@9.15.2"
55+
}

0 commit comments

Comments
 (0)