Skip to content

Commit ccf7c50

Browse files
Merge branch 'pnpm-workspaces' into alpha
# Conflicts: # yarn.lock
2 parents 5fc1e33 + 7b05648 commit ccf7c50

File tree

197 files changed

+49964
-45293
lines changed

Some content is hidden

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

197 files changed

+49964
-45293
lines changed

.github/workflows/codespell.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ jobs:
1414
check_filenames: true
1515
ignore_words_list: MapPin
1616
# skip git, yarn, mocks, and i18n resources.
17-
skip: ./.git,yarn.lock,*__mocks__/*,*__snapshots__/*,*i18n/*,otpSchema.json
17+
skip: ./.git,pnpm-lock.yaml,*__mocks__/*,*__snapshots__/*,*i18n/*,otpSchema.json

.github/workflows/node-ci.yml

+16-12
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,42 @@ jobs:
55
- uses: actions/checkout@v2
66
with:
77
persist-credentials: false
8+
- uses: pnpm/action-setup@v2
9+
with:
10+
version: 9
811
- name: Use Node.js 21.x
9-
uses: actions/setup-node@v1
12+
uses: actions/setup-node@v4
1013
with:
1114
node-version: 21.x
12-
- name: Install npm packages using cache
13-
uses: bahmutov/npm-install@v1
15+
cache: "pnpm"
16+
- name: Install dependencies
17+
run: pnpm install --frozen-lockfile
1418
- name: Install Playwright
15-
run: npx playwright install --with-deps
19+
run: pnpm exec playwright install --with-deps
1620
- name: Lint code
17-
run: yarn lint:js
21+
run: pnpm run lint:js
1822
- name: Lint styles
19-
run: yarn lint:styles
23+
run: pnpm run lint:styles
2024
- name: i18n check (en-US, fr only)
21-
run: yarn check:i18n-en-fr
25+
run: pnpm run check:i18n-en-fr
2226
- name: Type check
23-
run: yarn typescript
27+
run: pnpm run typescript
2428
- name: Run unit tests
25-
run: yarn unit
29+
run: pnpm run unit
2630
- name: Build Storybook
27-
run: yarn build-storybook --quiet
31+
run: pnpm run build-storybook --quiet
2832
- name: Serve Storybook and run test runner
2933
# env:
3034
# ONLY_RUN: SNAPSHOTS
3135
run: |
3236
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
3337
"npx http-server storybook-static --port 5555 --silent" \
34-
"npx wait-on tcp:5555 && yarn test-storybook --ci"
38+
"npx wait-on tcp:5555 && pnpm run test-storybook --ci"
3539
- env:
3640
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3741
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
3842
name: Semantic Release
39-
run: yarn semantic-release
43+
run: pnpm run semantic-release
4044
name: Node.js CI
4145
"on":
4246
pull_request: null

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ node_modules
77
.idea
88
storybook-static/
99
*.tsbuildinfo
10-
.vscode/
10+
.vscode/
11+
*.tgz

.npmrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node-linker=hoisted
2+
shamefully-hoist=true
3+
strict-peer-dependencies=false

.storybook/main.js

+12
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ module.exports = {
6565
}
6666
})
6767

68+
// Add fallback for querystring
69+
config.resolve.fallback = {
70+
...config.resolve.fallback,
71+
querystring: require.resolve('querystring-es3')
72+
};
73+
74+
// Configure module resolution for workspace packages
75+
config.resolve.alias = {
76+
...config.resolve.alias,
77+
'@opentripplanner': path.resolve(__dirname, '../packages')
78+
};
79+
6880
// Return the altered config
6981
return config;
7082
},

README.md

+14-21
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,28 @@ See:
1717

1818
```bash
1919
git checkout https://github.com/opentripplanner/otp-ui.git
20-
yarn dev # (installs packages, transpiles files, opens storybook to running component library on localhost:5555)
20+
pnpm install
21+
pnpm dev
2122
```
2223

2324
## Development
2425

2526
You can chat with the main OTP-RR developers in our [Gitter chat](https://gitter.im/opentripplanner/otp-react-redux). Support is not guaranteed, but we may be able to answer questions and assist people wishing to make contributions.
2627

27-
Some packages in otp-ui depend on sibling packages (e.g., `@opentripplanner/core-utils` is used by many of its siblings). In order to test a package with local changes you have made to its sibling, you can run the following find/replace operations to make sure you're depending on your latest work (and not the released version):
28-
29-
1. In the `package.json` files for packages in which you want to test the sibling, find and replace (package-to-test being the package with local changes -- make sure these are committed to first to avoid the find/replace operations below polluting your work):
30-
31-
> "@opentripplanner/package-to-test": **"current-version"**
32-
33-
with
34-
35-
> "@opentripplanner/package-to-test": **"file:../package-to-test"**
36-
37-
2. Run:
38-
`yarn && yarn dev`
28+
Some packages in otp-ui depend on sibling packages (e.g., `@opentripplanner/core-utils` is used by many of its siblings). Internal dependencies are handled with the `workspace:*` version, which is a notation provided by pnpm. This allows us to always reference the current internal dependency version. Therefore, before the storybook can be run, it's necessary to run `pnpm prepublish` so that all internal packages are built.
3929

4030
If the Storybook addon bar (a bar of controls at the bottom of the story) does not appear, you may need to clear localStorage by opening the browser console and typing `localStorage.clear()`.
4131

4232
### Storyshot testing
4333

44-
This repo utilizes the [Storyshot](https://storybook.js.org/docs/react/workflows/snapshot-testing) Storybook addon to perform snapshot tests of every story in this monorepo. Whenever the script `yarn unit` is ran, the Storyshot addon will be included along with all the other tests. It will compare the initial output of every story to the saved snapshot of that story. This provides a quick way to make sure nothing drastic has changed and that every single story is able to initially render without an error. Storyshot doesn't snapshot all possible changes that can be done while interacting with story components. Often times these snapshots will need to be updated and that can be accomplished by running `yarn unit -u`.
34+
This repo utilizes the [Storyshot](https://storybook.js.org/docs/react/workflows/snapshot-testing) Storybook addon to perform snapshot tests of every story in this monorepo. Whenever the script `pnpm unit` is ran, the Storyshot addon will be included along with all the other tests. It will compare the initial output of every story to the saved snapshot of that story. This provides a quick way to make sure nothing drastic has changed and that every single story is able to initially render without an error. Storyshot doesn't snapshot all possible changes that can be done while interacting with story components. Often times these snapshots will need to be updated and that can be accomplished by running `pnpm update-snapshots`.
4535

4636
## Stack
4737

4838
> A Monorepo with multiple packages and a shared build, test, and release process.
4939
5040
- 🐉 [Lerna](https://lernajs.io/)  - The Monorepo manager
51-
- 📦 [Yarn Workspaces](https://yarnpkg.com/lang/en/docs/workspaces/)  -  Sane multi-package management
41+
- 📦 [PNPM Workspaces](https://pnpm.io/workspaces)  -  Sane multi-package management
5242
- 🚀 [React](https://reactjs.org/)  -  JavaScript library for user interfaces
5343
- 💅 [styled-components](https://www.styled-components.com/)  -  CSS in JS elegance
5444
- 🛠 [Babel](https://babeljs.io/)  -  Compiles next-gen JavaScript
@@ -57,11 +47,12 @@ This repo utilizes the [Storyshot](https://storybook.js.org/docs/react/workflows
5747

5848
## Usage
5949

60-
- `yarn dev` - This starts Storybook for viewing all the components locally.
61-
- `yarn bootstrap` - This installs all of the packages and links dependent packages together.
62-
- `yarn preppublish` - This babelfies all of the packages and creates `/lib` folders for each one.
63-
- `yarn unit` - Run jest unit tests.
64-
- `yarn coverage` - Shows jest unit coverage.
50+
- `pnpm dev` - This starts Storybook for viewing all the components locally.
51+
- `pnpm install` - This installs all of the packages and links dependent packages together.
52+
- `pnpm preppublish` - This babelfies all of the packages and creates `/lib` and `/esm` folders for each one.
53+
- `pnpm unit` - Run jest unit tests.
54+
- `pnpm coverage` - Shows jest unit coverage.
55+
- `pnpm clean` - Deletes all files in the gitignore (note: this can delete local editor settings)
6556
- `npx lerna changed` - Show which packages have changed.
6657
- `npx lerna diff` - Show specifically what files have cause the packages to change.
6758
- `npx lerna create <packageName>` - Creates new package and walks through setting up package.json
@@ -70,7 +61,9 @@ This repo utilizes the [Storyshot](https://storybook.js.org/docs/react/workflows
7061

7162
This project uses semantic-release to create releases to NPM. It is expect that contributors create [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) messages. These are then parsed by semantic-release which will automatically create an appropriate release for each package whenever a branch is merged to master.
7263

73-
Sometimes when creating new releases, it will be necessary to update numerous packages within this repo at once to a newer internal package version. For this purpose there is the `update-internal-dependencies` script. This should be ran manually as needed. By default, `yarn update-internal-dependencies` will update all dependencies with the `@opentripplanner` scope in all packages within this project. To only update specific dependencies, it is possible to run something like `yarn update-internal-dependencies core-utils base-map`. This would update all dependencies on either the `@opentripplanner/base-map` or the `@opentripplanner/core-utils` in all packages in this project.
64+
Internal package dependencies are referenced using the `workspace` [protocol provided by pnpm](https://pnpm.io/workspaces). This allows us to depend on our internal packages without keeping versions up to date, but these versions must be replaced with the actual version numbers prior to release. pnpm handles this when publishing automatically. However, if you wish to rely on an otp-ui package in a local filesystem project using the `file` protocol, you need to use `pnpm pack` to create a tarball of the package, then reference that tarball in the other project's package.json.
65+
66+
For example, to depend on core-utils locally, you can run `pnpm pack` from within the `packages/core-utils`. Next, in the other project, use a line like this to reference the resulting tarball. `"@opentripplanner/core-utils": "file:../otp-ui/packages/core-utils/opentripplanner-core-utils-12.0.2.tgz",`
7467

7568
## Raster Tile Versions
7669

babel.config.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
},
77
"plugins": [
88
["@babel/plugin-proposal-class-properties", { "loose": true }],
9-
["@babel/plugin-proposal-private-methods", { "loose": true }],
10-
["@babel/plugin-proposal-private-property-in-object", { "loose": true }],
9+
["@babel/plugin-transform-private-methods", { "loose": true }],
10+
["@babel/plugin-transform-private-property-in-object", { "loose": true }],
1111
"babel-plugin-styled-components",
1212
"@babel/plugin-transform-runtime",
1313
"import-graphql",

jest.config.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ module.exports = {
3030
testPathIgnorePatterns: ["<rootDir>/packages/(?:.+?)/((esm)|(lib))/"],
3131
transform: {
3232
"\\.[jt]sx?$": "babel-jest",
33-
"\\.ya?ml$": "yaml-jest"
34-
}
33+
"\\.ya?ml$": "yaml-jest",
34+
"node_modules/chroma-js/.+\\.js$": "<rootDir>/transform-esm-modules.js"
35+
},
36+
transformIgnorePatterns: ["/node_modules/(?!(chroma-js)/)"]
3537
};

lerna.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"packages": ["packages/*"],
3-
"npmClient": "yarn",
4-
"userWorkspaces": true,
3+
"npmClient": "pnpm",
54
"version": "independent"
65
}

package.json

+22-16
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
"version": "0.0.1",
44
"private": true,
55
"engines": {
6-
"node": ">=12"
6+
"node": ">=12",
7+
"pnpm": ">=8"
78
},
8-
"workspaces": [
9-
"packages/*"
10-
],
9+
"packageManager": "[email protected]",
1110
"resolutions": {
1211
"react": "18.2.0",
1312
"react-animate-height": "3.0.4"
@@ -17,7 +16,10 @@
1716
"@babel/core": "^7.10",
1817
"@babel/plugin-proposal-class-properties": "^7.10",
1918
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
20-
"@babel/plugin-proposal-private-property-in-object": "^7.14.0",
19+
"@babel/plugin-proposal-private-methods": "^7.18.6",
20+
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
21+
"@babel/plugin-transform-private-methods": "^7.23.3",
22+
"@babel/plugin-transform-private-property-in-object": "^7.23.4",
2123
"@babel/plugin-transform-runtime": "^7.14.5",
2224
"@babel/preset-env": "^7.10",
2325
"@babel/preset-react": "^7.10",
@@ -39,7 +41,7 @@
3941
"@storybook/react": "7.6.17",
4042
"@storybook/react-webpack5": "7.6.17",
4143
"@storybook/storybook-deployer": "^2.8.10",
42-
"@storybook/test-runner": "^0.17.0",
44+
"@storybook/test-runner": "^0.16.0",
4345
"@types/jest": "^26.0.23",
4446
"@types/node": "^15.0.0",
4547
"@types/styled-components": "^5.1.9",
@@ -74,15 +76,16 @@
7476
"jest-styled-components": "^7.0.5",
7577
"js-yaml": "^4.1.0",
7678
"json-loader": "^0.5.7",
77-
"lerna": "^3.18.4",
79+
"lerna": "^8.1.9",
7880
"lint-staged": "^8.2.0",
7981
"msw": "^2.3.1",
8082
"nock": "^11.7.0",
8183
"prettier": "^1.19.1",
8284
"puppeteer": "^10.2.0",
85+
"querystring-es3": "^0.2.1",
8386
"react": "^18.2.0",
8487
"react-dom": "^18.2.0",
85-
"react-intl": "^5.24.6",
88+
"react-intl": "^6.8.4",
8689
"react-test-renderer": "^16.14.0",
8790
"semantic-release": "^17.1.1",
8891
"semantic-release-monorepo": "^7.0.2",
@@ -103,32 +106,35 @@
103106
"yaml-sort": "^2.0.0"
104107
},
105108
"scripts": {
106-
"bootstrap": "lerna bootstrap --use-workspaces",
109+
"bootstrap": "pnpm install",
110+
"preinstall": "npx only-allow pnpm",
107111
"build:cjs": "lerna exec --parallel -- babel --extensions '.js,.ts,.tsx,.snap' --ignore **/*.story.js,**/*.story.ts,**/*.story.d.ts,**/*.story.tsx,**/*.spec.js,**/*.spec.ts,**/*.test.js,**/*.test.ts,**/__tests__/**,**/__unpublished__/**,**/*.snap --ignore **/__tests__/** -D --no-copy-ignored --root-mode upward --source-maps true src -d lib",
108112
"build:esm": "lerna exec --parallel -- cross-env BABEL_ENV=esm babel --extensions '.js,.ts,.tsx,.snap' --ignore **/*.story.js,**/*.story.ts,**/*.story.d.ts,**/*.story.tsx,**/*.spec.js,**/*.spec.ts,**/*.test.js,**/*.test.ts,**/__tests__/**,**/__unpublished__/**,**/*.snap --ignore **/__tests__/** -D --no-copy-ignored --root-mode upward --source-maps true src -d esm",
109113
"check:i18n-all": "node packages/scripts/lib/run-validate-i18n.js packages/**/src packages/**/i18n",
110114
"check:i18n-en-fr": "node packages/scripts/lib/run-validate-i18n.js packages/**/src packages/**/i18n/en-US.yml packages/**/i18n/fr.yml",
111115
"clean": "git clean -Xdf",
112-
"prepublish": "yarn typescript && yarn build:cjs && yarn build:esm",
116+
"prepublish": "pnpm typescript && pnpm build:cjs && pnpm build:esm",
113117
"check-eslint-config": "eslint --print-config jestconfig.js | eslint-config-prettier-check",
114118
"coverage": "jest --coverage",
115119
"deploy-storybook": "storybook-to-ghpages",
116120
"dev": "storybook dev -p 5555",
117-
"predev": "yarn",
121+
"postinstall": "pnpm prepublish",
122+
"predev": "pnpm install",
118123
"build-storybook": "storybook build",
119124
"lint:js": "eslint . --ext .js,.jsx,.ts,.tsx --ignore-pattern esm --ignore-pattern lib --ignore-pattern node_modules --ignore-pattern storybook-static --quiet",
120125
"lint:graphql": "eslint . --ext .graphql --ignore-pattern esm --ignore-pattern lib --ignore-pattern node_modules --ignore-pattern storybook-static",
121126
"lint:fixjs": "eslint . --ext .js,.jsx,.ts,.tsx --ignore-pattern esm --ignore-pattern lib --ignore-pattern node_modules --ignore-pattern storybook-static --fix",
122127
"lint:styles": "stylelint \"packages/**/!(*.d).{j,t}s{,x}\"",
123-
"lint": "yarn lint:js && yarn lint:styles && yarn lint:graphql",
128+
"lint": "pnpm lint:js && pnpm lint:styles && pnpm lint:graphql",
124129
"prettier": "prettier --write \"**/*.{json,md,yml}\"",
125130
"semantic-release": "lerna exec --concurrency 1 -- semantic-release -e semantic-release-monorepo",
126-
"test": "yarn lint:js && yarn lint:styles && yarn check:i18n-en-fr && yarn typescript && yarn unit && yarn test-storybook && yarn a11y-test",
131+
"test": "pnpm lint:js && pnpm lint:styles && pnpm check:i18n-en-fr && pnpm typescript && pnpm unit && pnpm test-storybook && pnpm a11y-test",
127132
"typescript": "lerna run tsc",
128133
"unit": "jest --testPathIgnorePatterns a11y .d.ts",
129134
"update-internal-dependencies": "node scripts/update-internal-dependencies.js",
130135
"test-storybook": "test-storybook --url http://localhost:5555",
131-
"update-snapshots": "yarn build-storybook; npx concurrently -k -s first -n \"SB,TEST\" \"npx http-server storybook-static --port 5555 --silent\" \"npx wait-on tcp:5555 && yarn test-storybook --url http://localhost:5555 -u\""
136+
"update-snapshots": "pnpm build-storybook; npx concurrently -k -s first -n \"SB,TEST\" \"npx http-server storybook-static --port 5555 --silent\" \"npx wait-on tcp:5555 && pnpm test-storybook --url http://localhost:5555 -u\"",
137+
"pack-all": "lerna exec --no-private -- 'pnpm pack && echo \"Package tarball: $(pwd)/$(ls *.tgz)\"'"
132138
},
133139
"eslintConfig": {
134140
"env": {
@@ -255,7 +261,7 @@
255261
"husky": {
256262
"hooks": {
257263
"pre-commit": "lint-staged",
258-
"pre-push": "yarn check-eslint-config && yarn lint"
264+
"pre-push": "pnpm check-eslint-config && pnpm lint"
259265
}
260266
},
261267
"lint-staged": {
@@ -270,7 +276,7 @@
270276
],
271277
"*.graphql": [
272278
"prettier --write",
273-
"yarn lint:graphql --fix",
279+
"pnpm lint:graphql --fix",
274280
"git add"
275281
],
276282
"!(.github/**).{yml,yaml}": [

packages/base-map/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
"private": false,
1111
"dependencies": {
1212
"mapbox-gl": "npm:[email protected]",
13-
"maplibre-gl": "^2.1.9",
1413
"react-map-gl": "^7.0.15",
15-
"@opentripplanner/building-blocks": "^2.0.0"
14+
"@opentripplanner/building-blocks": "workspace:*"
1615
},
1716
"peerDependencies": {
17+
"maplibre-gl": "^2.1.9",
1818
"react": "^18.2.0",
19-
"@opentripplanner/types": "^6.5.2",
19+
"@opentripplanner/types": "workspace:*",
2020
"styled-components": "^5.3.0"
2121
},
2222
"repository": {

packages/base-map/src/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useCallback, useEffect, useState } from "react";
2-
import { Map, MapProps } from "react-map-gl";
2+
import { Map, MapProps } from "react-map-gl/maplibre";
33
import maplibregl, { Event } from "maplibre-gl";
44

55
import { useIntl } from "react-intl";

packages/building-blocks/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"module": "esm/index.js",
1010
"private": false,
1111
"devDependencies": {
12-
"@opentripplanner/types": "^6.5.2",
13-
"@opentripplanner/core-utils": "^12.0.0"
12+
"@opentripplanner/types": "workspace:*",
13+
"@opentripplanner/core-utils": "workspace:*"
1414
},
1515
"peerDependencies": {
1616
"react": "^18.2.0",

0 commit comments

Comments
 (0)