|
1 | 1 | # Commercial Monorepo |
2 | 2 |
|
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. |
4 | 4 |
|
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. |
10 | 8 |
|
11 | 9 | ## Development |
12 | 10 |
|
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 | | - |
15 | 11 | ### Requirements |
16 | 12 |
|
17 | 13 | - Node |
18 | | - - see [.nvmrc](../.nvmrc) for the current version |
| 14 | + - see [.nvmrc](./.nvmrc) for the current version |
19 | 15 | - 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) |
20 | 16 | - pnpm |
21 | 17 |
|
22 | 18 | ### Setup |
23 | 19 |
|
24 | 20 | To install dependencies, run `pnpm`. |
25 | 21 |
|
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. |
82 | 24 |
|
83 | | -### Deploying to PROD |
| 25 | +`@guardian/commercial-bundle` is deployed to PROD automatically when merged to main. It does not use changesets. |
84 | 26 |
|
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. |
86 | 28 |
|
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. |
0 commit comments