Skip to content

Commit a6f565a

Browse files
chore: Avoid running postinstall scripts (#13830)
* chore: Avoid running postinstall scripts These are a security risk, let's not run them if not needed This might not work because yarn 1 doesn't let us choose what dependencies are allowed to run postinstall scripts. We'll need to migrate to pnpm if we fail to build the app with these changes. * chore: Migrate to pnpm yarn is very hard to make it safe after today's supply chain attack, let's use pnpm - same as our main repo * feat: Add missing dep This worked when using yarn because a dependency installed this, but this stopped working when using pnpm because it installs files in different places * chore: Add existing dependencies to list * fix: Update browserslist * fix: Fix incorrect advice * feat: Add all missing deps to package.json We were previously using yarn and on yarn you can require transitive dependencies because files are installed like this ``` node_modules | node | posthog-js | posthog-js-dependency-i-can-require ``` on pnpm, on the other hand, they're nested, which means we cannot require dependencies we didn't install - which is much saner This meant we had to install more packages than before to get this to work * chore: add axios * chore: sort package.json * chore: Update pnpm lock
1 parent c30508d commit a6f565a

File tree

13 files changed

+39246
-30932
lines changed

13 files changed

+39246
-30932
lines changed

.cursor/rules/environment-structure.mdc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ It's a static website built on Gatsby and hosted with Vercel.
1212

1313
## Resources and servers
1414

15-
- Use yarn instead of npm
16-
- Run the app with `yarn start`. To make sure everything is fresh, run `yarn clean && yarn && yarn start`.
15+
- Use pnpm instead of npm
16+
- Run the app with `pnpm start`. To make sure everything is fresh, run `pnpm clean && pnpm && pnpm start`.
1717
- The site runs on port `8001`. If you need to test something, check if it's already running on that port – no need to spin up a new server if so.
1818
- Sometimes the project is run inside a parent folder so a VS Code Workspace can include the squeak-strapi repo in another subfolder. Always verify your directory when searching for files or trying to run commands.
1919

.github/workflows/internal-links-check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ jobs:
3232
uses: actions/setup-node@v4
3333
with:
3434
node-version: '22'
35-
cache: 'yarn'
35+
cache: 'pnpm'
3636

3737
- name: Install dependencies
38-
run: yarn install --frozen-lockfile
38+
run: pnpm install --frozen-lockfile
3939

4040
- name: Build site
41-
run: yarn build
41+
run: pnpm build
4242

4343
- name: Check links (console only)
4444
if: ${{ github.event_name == 'workflow_dispatch' && inputs.save_results == false }}

.gitignore

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
# Project dependencies
22
.cache
33
node_modules
4-
yarn-error.log
54
.pnp.*
6-
.yarn/*
7-
!.yarn/patches
8-
!.yarn/plugins
9-
!.yarn/releases
10-
!.yarn/sdks
11-
!.yarn/versions
125

136
# Build directory
147
/public
@@ -27,7 +20,6 @@ static/fonts/MatterSQItalicVF.woff2
2720
static/fonts/MatterSQVF.woff
2821
static/fonts/MatterSQVF.woff2
2922
static/scripts/posthog-init.js
30-
yarn.lock
3123
.vercel
3224
.env
3325
*Type.ts

.yarnrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This is the repository for the PostHog website. It contains:
3434

3535
Install [Node](https://nodejs.org/en/download/) (version 22) - if you installed Node using nvm, you can run `nvm use` to automatically switch to the correct version.
3636

37-
Install [Yarn](https://yarnpkg.com/getting-started/install). (If you're on a Mac with Apple Silicon and get an error with `-86` in it, you may need to [install Rosetta](https://osxdaily.com/2020/12/04/how-install-rosetta-2-apple-silicon-mac/).)
37+
Install `pnpm`. The easiest way to do this is via `corepack use pnpm@latest-10`.
3838

3939

4040
2. **Start developing**
@@ -55,8 +55,8 @@ This is the repository for the PostHog website. It contains:
5555
Then install the site dependencies, and start it up:
5656

5757
```bash
58-
yarn
59-
yarn start
58+
pnpm install
59+
pnpm start
6060
```
6161

6262
> **Tip:** Seeing a discrepancy between local development and staging/production? Preview the production build locally by running `gatsby build && gatsby serve`
@@ -73,15 +73,15 @@ See full instructions on [developing PostHog.com locally in our manual](https://
7373
7474
### Debugging errors on start
7575
1. Pull the latest changes from `master`
76-
2. Run `gatsby clean && yarn start` or delete `node_modules` and `.cache`
76+
2. Run `gatsby clean && pnpm start` or delete `node_modules` and `.cache`
7777
3. Check builds are passing in [deployment to Vercel](https://github.com/PostHog/posthog.com/deployments)
7878
7979
### Working on `/docs/api`?
8080
8181
The site will load the API schema from US Cloud by default. You can override this to use your local PostHog instance with an env var:
8282
8383
```
84-
POSTHOG_OPEN_API_SPEC_URL="http://127.0.0.1:8000/api/schema/" yarn start
84+
POSTHOG_OPEN_API_SPEC_URL="http://127.0.0.1:8000/api/schema/" pnpm start
8585
```
8686
8787
@@ -104,7 +104,7 @@ Currently, these environment variables are excluded from Vercel preview builds t
104104
105105
To develop a dynamic open graph image:
106106
107-
1. Run `yarn build` with both the `ASHBY_API_KEY` and `GITHUB_API_KEY` set.
107+
1. Run `pnpm build` with both the `ASHBY_API_KEY` and `GITHUB_API_KEY` set.
108108
1. In `gatsby/onPostBuild.ts`, temporarily comment out the following:
109109
```
110110
if (process.env.VERCEL_GIT_COMMIT_REF !== 'master') return

contents/blog/automating-a-software-company-with-github-actions.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
node-version: 14
102102

103103
- name: Install dependencies
104-
run: yarn
104+
run: pnpm install
105105

106106
- name: Build and start application
107107
run: echo "This is where you boot your application for testing"
@@ -150,14 +150,14 @@ jobs:
150150
with:
151151
node-version: 14
152152
153-
- name: Install package.json dependencies with Yarn
154-
run: yarn
153+
- name: Install package.json dependencies with Pnpm
154+
run: pnpm
155155
156156
- name: Check formatting with prettier
157-
run: yarn prettier .
157+
run: pnpm prettier .
158158
159159
- name: Lint with ESLint
160-
run: yarn eslint .
160+
run: pnpm eslint .
161161
```
162162

163163
> One thing we've not covered yet is what running jobs on every PR gives us in practice.

contents/handbook/content/docs-style-guide.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ To debug, check for the common issues below:
364364
You can also try running the formatter script to fix some of the issues:
365365

366366
```bash
367-
yarn format:docs
367+
pnpm format:docs
368368
```
369369

370370
This will run the formatter against the current changes.

contents/handbook/engineering/posthog-com/developing-the-website.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ Below, we'll explain the two options for option two.
3131

3232
When completed, press any key.
3333

34-
1. In terminal, type `yarn && yarn start` and hit [Enter].
34+
1. In terminal, type `pnpm install && pnpm start` and hit [Enter].
3535

36-
![yarn start](https://res.cloudinary.com/dmukukwp6/image/upload/codespaces_yarn_b02a89ed6b.png)
36+
![pnpm start](https://res.cloudinary.com/dmukukwp6/image/upload/codespaces_yarn_b02a89ed6b.png)
3737

3838
- This will take a while. The last step of the process is "Building development bundle" which will take a few minutes on its own.
3939
- You may see a dialog that says, "Your application running on port 8001 is available." Don't be enticed by the big green button quite yet.
@@ -89,7 +89,7 @@ In order to run the PostHog website locally, you need the following installed:
8989

9090
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) – version control system
9191
- [Node.js](https://nodejs.org/en/download/) (version 22.x) – server runtime
92-
- [Yarn](https://classic.yarnpkg.com/en/docs/install) (version 1.x) – package manager for Node.js
92+
- [pnpm](https://pnpm.io/installation) (version 10.x) – package manager for Node.js
9393
- [Apple Rosetta](https://support.apple.com/en-gb/HT211861) (version 2) – dynamic binary translator for Apple silicon
9494

9595
If you are unfamiliar with using Git from the command line (or just prefer graphical interfaces), use the [GitHub Desktop app](https://desktop.github.com/).
@@ -143,7 +143,7 @@ To work on it locally, first you need to clone it to your disk:
143143
144144
### Running posthog.com locally
145145
146-
If you're using an Apple Silicon Mac (M1+) then you'll need to run the following commands before using yarn:
146+
If you're using an Apple Silicon Mac (M1+) then you'll need to run the following commands before using pnpm:
147147
148148
```bash
149149
rm -rf ./node_modules
@@ -153,27 +153,27 @@ brew install vips
153153
Type the following into the command line and press return:
154154
155155
```bash
156-
yarn
156+
pnpm install
157157
```
158158
159-
This runs the Yarn tool. When run standalone like this, it installs the dependency packages used by posthog.com. This may take a few minutes.
159+
This installs the dependency packages used by posthog.com. This may take a few minutes.
160160
161161
After initial setup, use the following command to start the development server:
162162
163163
```bash
164-
yarn && yarn start
164+
pnpm install && pnpm start
165165
```
166166
167167
This runs the local clone of the website, which you can use to preview changes you make before pushing them live. It takes a bit of time for some file processing and compilation to take place, but once it's completed you can access the locally running version of posthog.com via by visiting `http://localhost:8001` in your web browser.
168168

169-
Any time you want to preview changes you are making to the local version of the website, all you have to do is run the `yarn start` again, wait for the command to finish running and then open `http://localhost:8001` in your web browser.
169+
Any time you want to preview changes you are making to the local version of the website, all you have to do is run the `pnpm start` again, wait for the command to finish running and then open `http://localhost:8001` in your web browser.
170170

171171
**Troubleshooting**
172172

173173
If the server fails to start, the first troubleshooting step is to clear cache. You can do this (and start the server again) by running:
174174

175175
```bash
176-
yarn clean && mkdir .cache && yarn && yarn start
176+
pnpm clean && mkdir .cache && pnpm install && pnpm start
177177
```
178178

179179
### Environment variables
@@ -538,7 +538,7 @@ After a series of checks are run (to ensure nothing in your pull request breaks
538538
539539
An initial build can take up to 50 minutes to run. After the initial build, subsequent builds should complete in under ~15 minutes. We're limited to two concurrent builds, so if there's a backlog, this process can take longer.
540540
541-
Because Vercel charges per seat, we don't automatically invite all team members to our Vercel account. If your build fails, you can run `yarn build` locally to see what's erroring out. If nothing is erroring locally, it's likely the build timed out in Vercel. The Website & Docs team monitors for failed builds, so they'll re-run it for you. If the build is urgent, give a shout in #team-website-and-docs and someone with Vercel access can trigger a rebuild for you.
541+
Because Vercel charges per seat, we don't automatically invite all team members to our Vercel account. If your build fails, you can run `pnpm build` locally to see what's erroring out. If nothing is erroring locally, it's likely the build timed out in Vercel. The Website & Docs team monitors for failed builds, so they'll re-run it for you. If the build is urgent, give a shout in #team-website-and-docs and someone with Vercel access can trigger a rebuild for you.
542542
543543
![Preview branch](https://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/docs/contribute/preview-branch.png)
544544

package.json

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,29 @@
3737
"@amcharts/amcharts5-geodata": "^5.1.5",
3838
"@dotlottie/react-player": "^1.6.6",
3939
"@fontsource/source-code-pro": "^4.5.4",
40+
"@gatsbyjs/reach-router": "^1.3.9",
4041
"@headlessui/react": "^1.7.13",
4142
"@headlessui/tailwindcss": "^0.1.1",
4243
"@heroicons/react": "^1.0.6",
4344
"@hubspot/api-client": "^7.1.2",
4445
"@inkeep/cxkit-react": "^0.5.93",
4546
"@inkeep/uikit": "^0.3.20",
4647
"@inkeep/uikit-js": "^0.3.20",
48+
"@lexical/utils": "^0.35.0",
49+
"@mdx-js/react": "^1.6.22",
4750
"@mdxeditor/editor": "^3.32.3",
4851
"@popperjs/core": "^2.11.2",
4952
"@posthog/hedgehog-mode": "^0.0.41",
5053
"@posthog/icons": "0.36.0",
5154
"@radix-ui/react-accordion": "^1.2.3",
55+
"@radix-ui/react-collapsible": "^1.1.12",
5256
"@radix-ui/react-icons": "^1.3.2",
5357
"@radix-ui/react-menubar": "^1.1.6",
58+
"@radix-ui/react-portal": "^1.1.9",
59+
"@radix-ui/react-radio-group": "^1.3.8",
60+
"@radix-ui/react-scroll-area": "^1.2.10",
5461
"@radix-ui/react-tabs": "^1.1.4",
62+
"@radix-ui/react-toolbar": "^1.1.11",
5563
"@tailwindcss/container-queries": "^0.1.1",
5664
"@tanstack/react-virtual": "^3.13.12",
5765
"@types/lodash.groupby": "^4.6.7",
@@ -61,19 +69,23 @@
6169
"@wistia/wistia-player-react": "^0.1.17",
6270
"ahooks": "^3.7.8",
6371
"algoliasearch": "^4.14.2",
72+
"axios": "^1.12.2",
6473
"chart.js": "^4.3.3",
6574
"chrome-aws-lambda": "^10.1.0",
6675
"cloudinary-react": "^1.8.1",
6776
"clsx": "^2.0.0",
6877
"cntl": "^1.0.0",
6978
"core-js": "^3.21.1",
7079
"dayjs": "^1.11.7",
80+
"deepmerge": "^4.3.1",
7181
"dotenv": "^10.0.0",
7282
"formik": "^2.2.9",
7383
"framer-motion": "^4.1.17",
84+
"fs-extra": "^10.1.0",
7485
"fuse.js": "^6.6.2",
7586
"gatsby": "4.25.9",
7687
"gatsby-cli": "^4.20.0",
88+
"gatsby-link": "^4.25.0",
7789
"gatsby-plugin-algolia": "^0.26.0",
7890
"gatsby-plugin-breakpoints": "^1.3.9",
7991
"gatsby-plugin-feed": "^4.20.0",
@@ -87,7 +99,9 @@
8799
"gatsby-plugin-react-svg": "^3.1.0",
88100
"gatsby-plugin-sitemap": "^5.20.0",
89101
"gatsby-plugin-smoothscroll": "^1.2.0",
102+
"gatsby-react-router-scroll": "^5.25.0",
90103
"gatsby-remark-autolink-headers": "^5.20.0",
104+
"gatsby-script": "^1.10.0",
91105
"gatsby-source-ashby": "^1.0.5",
92106
"gatsby-source-filesystem": "^4.20.0",
93107
"gatsby-source-git": "^1.1.0",
@@ -97,6 +111,7 @@
97111
"glob": "^10.3.10",
98112
"html-to-image": "^1.11.11",
99113
"instantsearch.js": "^4.49.1",
114+
"is-relative": "^1.0.0",
100115
"jsdom": "^20.0.0",
101116
"jspdf": "^3.0.1",
102117
"kea": "3.1.6",
@@ -105,6 +120,8 @@
105120
"kea-router": "^3.1.6",
106121
"kea-typegen": "^3.1.6",
107122
"keen-slider": "^6.8.6",
123+
"lexical": "^0.35.0",
124+
"lodash": "^4.17.21",
108125
"lodash.get": "^4.4.2",
109126
"lodash.groupby": "^4.6.0",
110127
"lodash.uniqby": "^4.7.0",
@@ -116,9 +133,12 @@
116133
"markdown-to-jsx": "^7.4.0",
117134
"md5": "^2.3.0",
118135
"mermaid": "^11.4.1",
136+
"mitt": "^1.2.0",
119137
"mobx": "^6.3.13",
120138
"multiparty": "^4.2.3",
121139
"node-fetch": "^2.6.1",
140+
"node-html-parser": "^5.4.2",
141+
"openapi-sampler": "^1.6.1",
122142
"p-limit": "3.1.0",
123143
"parse-link-header": "^2.0.0",
124144
"patch-package": "^8.0.0",
@@ -127,6 +147,7 @@
127147
"posthog-node": "^4.2.0",
128148
"prism-react-renderer": "^1.3.5",
129149
"prismjs": "^1.29.0",
150+
"prop-types": "^15.8.1",
130151
"puppeteer-core": "^13.0.1",
131152
"qs": "^6.11.1",
132153
"query-string": "^6.13.1",
@@ -174,6 +195,7 @@
174195
"request": "^2.88.2",
175196
"sass": "^1.43.2",
176197
"scrapingbee": "^1.7.5",
198+
"shallow-compare": "^1.2.2",
177199
"slugify": "^1.6.0",
178200
"styled-components": "^5.3.3",
179201
"svg-sprite": "^1.5.0",
@@ -243,13 +265,32 @@
243265
"resolutions": {
244266
"undici": "5.26.3"
245267
},
246-
"workspaces": [
247-
"plugins/*"
248-
],
249268
"lint-staged": {
250269
"*.{html,js,ts,tsx,json,yml,css,scss}": "prettier --write",
251270
"*.{js,ts,tsx}": "eslint",
252271
"*.{md,mdx}": "markdownlint-cli2 --fix"
253272
},
254-
"packageManager": "[email protected]"
273+
"packageManager": "[email protected]+sha512.21c4e5698002ade97e4efe8b8b4a89a8de3c85a37919f957e7a0f30f38fbc5bbdd05980ffe29179b2fb6e6e691242e098d945d1601772cad0fef5fb6411e2a4b",
274+
"pnpm": {
275+
"onlyBuiltDependencies": [
276+
"@parcel/watcher",
277+
"core-js",
278+
"core-js-pure",
279+
"es5-ext",
280+
"esbuild",
281+
"fsevents",
282+
"gatsby",
283+
"gatsby-cli",
284+
"gatsby-telemetry",
285+
"husky",
286+
"lmdb",
287+
"msgpackr-extract",
288+
"phantomjs-prebuilt",
289+
"postinstall-postinstall",
290+
"puppeteer",
291+
"react-tsparticles",
292+
"sharp",
293+
"tsparticles-engine"
294+
]
295+
}
255296
}

0 commit comments

Comments
 (0)