Skip to content

Commit 9f298ef

Browse files
authored
refactor(project): update structure to monorepo (#4136)
* refactor(project): update root package.json to workspaces * refactor(project): move @primer/react to packages/react * refactor(project): add examples to workspaces * refactor(project): move eslint to top-level * refactor(project): move markdownlint to top-level * refactor(project): move prettier to top-level * refactor(project): move jest to top-level, add support for projects * chore(react): remove lint-staged config from packages/react * refactor(project): update TypeScript to work across workspaces * refactor(project): setup clean and build commands across workspaces * refactor(project): add docs as workspace * refactor(ci): update ci to use new project structure * refactor(ci): add todo stubs for release step * revert(ci): remove changes to ci * refactor(ci): update ci to use new project structure * chore(project): address eslint violations * chore(react): add negation pattern for codemods/lib * fix(ci): update scripts for deploy preview * chore(npm): update build:storybook npm script to use local script * refactor(project): move size-limit to top-level * ci(consumer_test): update test to work with new structure * refactor: move consumer-test into examples * chore: update lockfile * ci: update vrt to use new monorepo paths * ci(consumer-test): update duplicate key * ci: fix pack output location * chore: remove prepare script for consumer_test workflow * ci(release): restore release workflow behaviors * chore: move legacy-theme into primer package * ci(release): update canary workflow to work with monorepo structure * ci(release): update canary release to adjust package.json structure * ci(release): remove 0.0.0 version since snapshot will create new version * chore: add private to workspaces * chore(docs): pin and hoist dependencies to prevent conflicts * chore(deps): update deps from latest * chore: add optional dependency for ci * chore(test): remove outdated snapshots * chore(gitignore): update to include .tsbuildinfo files * chore: update package versions for workspaces --------- Co-authored-by: Josh Black <[email protected]>
1 parent 13c06b8 commit 9f298ef

File tree

948 files changed

+49206
-113403
lines changed

Some content is hidden

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

948 files changed

+49206
-113403
lines changed

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"access": "public",
77
"baseBranch": "main",
88
"updateInternalDependencies": "patch",
9-
"ignore": []
9+
"ignore": ["docs", "example-*"]
1010
}

.eslintignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
**/node_modules/**
2+
**/storybook-static/**
3+
**/.next/**
4+
**/lib/**
5+
**/lib-esm/**
6+
**/dist/**
7+
8+
script/**/*.ts

.eslintrc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module.exports = {
4444
'contributor-docs/adrs/*',
4545
'examples/nextjs/**',
4646
// Note: this file is inlined from an external dependency
47-
'src/utils/polymorphic.ts',
47+
'packages/react/src/utils/polymorphic.ts',
4848
'storybook-static',
4949
'CHANGELOG.md',
5050
],
@@ -107,7 +107,7 @@ module.exports = {
107107
// rules which apply only to TS
108108
{
109109
parserOptions: {
110-
project: 'tsconfig.json',
110+
project: ['./tsconfig.json', './packages/**/tsconfig.json', './examples/**/tsconfig.json'],
111111
},
112112
files: ['**/*.{ts,tsx}'],
113113
extends: ['plugin:@typescript-eslint/recommended'],
@@ -159,7 +159,7 @@ module.exports = {
159159

160160
// Tests
161161
{
162-
files: ['src/**/*.test.{ts,tsx}'],
162+
files: ['**/*.test.{ts,tsx}'],
163163
extends: ['plugin:jest/recommended', 'plugin:testing-library/react'],
164164
rules: {
165165
'@typescript-eslint/no-non-null-assertion': 'off',

.github/workflows/ci.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,33 +90,22 @@ jobs:
9090
run: npm ci
9191

9292
- name: Type check
93-
run: npm run test:type-check
93+
run: npm run type-check
9494

9595
examples:
9696
runs-on: ubuntu-latest
9797
steps:
9898
- name: Checkout repository
9999
uses: actions/checkout@v4
100-
101100
- name: Set up Node.js
102101
uses: actions/setup-node@v4
103102
with:
104103
node-version: 20
105104
cache: 'npm'
106-
107105
- name: Install dependencies
108106
run: npm ci
109-
110107
- name: Build
111-
run: npm run build
112-
113-
- name: Install examples dependencies
114-
working-directory: examples/nextjs
115-
run: npm ci
116-
117-
- name: Build examples
118-
working-directory: examples/nextjs
119-
run: npm run build
108+
run: npm run build -ws --if-present
120109

121110
vrt-runner:
122111
runs-on: ubuntu-latest-8-cores
@@ -135,8 +124,10 @@ jobs:
135124
run: npm ci
136125
- name: Build storybook
137126
run: npx storybook build
127+
working-directory: packages/react
138128
- name: Run storybook
139129
id: storybook
130+
working-directory: packages/react
140131
run: |
141132
npx serve -l 6006 storybook-static &
142133
pid=$!
@@ -203,8 +194,10 @@ jobs:
203194
run: npm ci
204195
- name: Build storybook
205196
run: npx storybook build
197+
working-directory: packages/react
206198
- name: Run storybook
207199
id: storybook
200+
working-directory: packages/react
208201
run: |
209202
npx serve -l 6006 storybook-static &
210203
pid=$!
@@ -284,4 +277,4 @@ jobs:
284277
- name: Build
285278
run: npm run build
286279
- name: Get export sizes
287-
run: node script/get-export-sizes.js
280+
run: node packages/react/script/get-export-sizes.js

.github/workflows/consumer_test.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,23 @@ jobs:
1616
with:
1717
node-version: 20
1818
cache: npm
19+
- name: Remove "prepare" script
20+
run: npm pkg delete scripts.prepare
1921
- name: Install dependencies
2022
run: npm ci
21-
- name: Build
22-
run: npm run build
23+
- name: Build @primer/react
24+
run: npm run build -w @primer/react
2325
# Output the artifact as a tarball in `consumer-test`. Write the
2426
# information for this package in `consumer-test/pack.json` so we can read
2527
# from it later to install the package
2628
- name: Create a tarball for the package
27-
run: npm pack --pack-destination consumer-test --json > consumer-test/pack.json
29+
run: npm pack --pack-destination ../../examples/consumer-test --json > ../../examples/consumer-test/pack.json
30+
working-directory: packages/react
2831
- name: Clean package directory
29-
run: |
30-
npm run clean
31-
rm -rf node_modules
32+
run: npm run clean:all
3233
- name: Test
3334
id: test
34-
working-directory: consumer-test
35+
working-directory: examples/consumer-test
3536
run: |
3637
# Read the filename for the tarball from `pack.json`
3738
npm install $(jq -r '.[0].filename' pack.json)
@@ -40,4 +41,4 @@ jobs:
4041
- name: Add annotation
4142
if: failure() && steps.test.conclusion == 'failure'
4243
run: |
43-
echo "::error file=tsconfig.build.json::Test package could not build. See https://github.com/primer/react/blob/main/consumer-test"
44+
echo "::error file=tsconfig.build.json::Test package could not build. See https://github.com/primer/react/blob/main/examples/consumer-test"

.github/workflows/deploy_preview.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ jobs:
2020
cache: 'npm'
2121
- name: Install dependencies
2222
run: npm ci
23-
- name: Install docs dependencies
24-
run: npm ci --legacy-peer-deps
25-
working-directory: docs
2623
- name: Build docs preview
2724
run: npm run build:docs:preview
2825
- uses: actions/upload-pages-artifact@v3

.github/workflows/deploy_production.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ jobs:
5656
gh_token: ${{ secrets.GITHUB_TOKEN }}
5757
with:
5858
node_version: 18
59-
install: npm ci && cd docs && npm ci --legacy-peer-deps && cd ..
59+
install: npm ci
6060
build: npm run build:docs
6161
output_dir: docs/public

.github/workflows/release_canary.yml

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,46 @@ on:
99
jobs:
1010
release:
1111
concurrency: npm-canary
12-
uses: primer/.github/.github/workflows/release_canary.yml@main
13-
secrets:
14-
gh_token: ${{ secrets.GITHUB_TOKEN }}
15-
npm_token: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
with:
17+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
18+
fetch-depth: 0
19+
- name: Set up Node
20+
uses: actions/setup-node@v4
21+
with:
22+
node_version: ${{ inputs.node_version }}
23+
- name: Install dependencies
24+
run: npm ci
25+
- name: Build
26+
run: npm run build --if-present
27+
- name: Create .npmrc
28+
run: |
29+
cat << EOF > "$HOME/.npmrc"
30+
//registry.npmjs.org/:_authToken=$NPM_TOKEN
31+
EOF
32+
env:
33+
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}
34+
- name: Publish canary release
35+
run: |
36+
echo -e "---\n$( jq .name packages/react/package.json ): patch\n---\n\nFake entry to force publishing" > .changeset/force-snapshot-release.md
37+
npx changeset version --snapshot
38+
npx changeset publish --tag canary
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
- name: Output canary version
42+
uses: actions/[email protected]
43+
with:
44+
script: |
45+
const package = require(`${process.env.GITHUB_WORKSPACE}/packages/react/package.json`)
46+
github.repos.createCommitStatus({
47+
owner: context.repo.owner,
48+
repo: context.repo.repo,
49+
sha: context.sha,
50+
state: 'success',
51+
context: `Published ${package.name}`,
52+
description: package.version,
53+
target_url: `https://unpkg.com/${package.name}@${package.version}/`
54+
})

.github/workflows/vrt.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ jobs:
4343
run: npm ci
4444
- name: Build storybook
4545
run: npx storybook build
46+
working-directory: packages/react
4647
- name: Run storybook
4748
id: storybook
4849
run: |
49-
npx serve -l 6006 storybook-static &
50+
npx serve -l 6006 packages/react/storybook-static &
5051
pid=$!
5152
echo "pid=$pid" >> $GITHUB_OUTPUT
5253
sleep 5

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# Build folders
22
dist/
33
lib/
4-
!codemods/lib/
4+
!packages/react/codemods/lib/
55
lib-esm/
66
css/
7-
/generated
87

98
# Editor
109
.DS_Store
@@ -35,3 +34,6 @@ coverage/
3534
# Playwright
3635
stats.html
3736
blob-report
37+
38+
# TypeScript
39+
*.tsbuildinfo

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ save=true
22
save-exact=true
33
# we create our tags in Releases now
44
git-tag-version=false
5+
legacy-peer-deps=true

docs/.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict'
2+
3+
module.exports = {}

docs/content/ActionList.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ storybook: '/react/storybook?path=/story/components-actionlist'
77
description: An ActionList is a list of items that can be activated or selected. ActionList is the base component for many menu-type components, including ActionMenu and SelectPanel.
88
---
99

10-
import data from '../../src/ActionList/ActionList.docs.json'
10+
import data from '../../packages/react/src/ActionList/ActionList.docs.json'
1111

1212
import {ActionList, Avatar} from '@primer/react'
1313
import {LinkIcon, AlertIcon, ArrowRightIcon} from '@primer/octicons-react'

docs/content/ActionMenu.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ storybook: '/react/storybook?path=/story/components-actionmenu'
88
description: An ActionMenu is an ActionList-based component for creating a menu of actions that expands through a trigger button.
99
---
1010

11-
import data from '../../src/ActionMenu/ActionMenu.docs.json'
11+
import data from '../../packages/react/src/ActionMenu/ActionMenu.docs.json'
1212

1313
import {Box, Avatar, ActionList, ActionMenu} from '@primer/react'
1414
import DeprecationBanner from '../components/DeprecationBanner'

docs/content/AnchoredOverlay.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ source: https://github.com/primer/react/blob/main/src/AnchoredOverlay/AnchoredOv
66
storybook: '/react/storybook?path=/story/behaviors-anchoredoverlay--default-portal'
77
---
88

9-
import data from '../../src/AnchoredOverlay/AnchoredOverlay.docs.json'
9+
import data from '../../packages/react/src/AnchoredOverlay/AnchoredOverlay.docs.json'
1010

1111
import DeprecationBanner from '../components/DeprecationBanner'
1212

docs/content/Autocomplete.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source: https://github.com/primer/react/tree/main/src/Autocomplete
77
storybook: '/react/storybook?path=/story/components-autocomplete'
88
---
99

10-
import data from '../../src/Autocomplete/Autocomplete.docs.json'
10+
import data from '../../packages/react/src/Autocomplete/Autocomplete.docs.json'
1111
import {Autocomplete} from '@primer/react'
1212
import DeprecationBanner from '../components/DeprecationBanner'
1313

docs/content/Avatar.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ componentId: avatar
55
source: https://github.com/primer/react/blob/main/src/Avatar
66
---
77

8-
import data from '../../src/Avatar/Avatar.docs.json'
8+
import data from '../../packages/react/src/Avatar/Avatar.docs.json'
99
import {Avatar, Box} from '@primer/react'
1010
import DeprecationBanner from '../components/DeprecationBanner'
1111

docs/content/AvatarPair.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ status: Alpha
55
source: https://github.com/primer/react/blob/main/src/AvatarPair
66
---
77

8-
import data from '../../src/AvatarPair/AvatarPair.docs.json'
8+
import data from '../../packages/react/src/AvatarPair/AvatarPair.docs.json'
99
import DeprecationBanner from '../components/DeprecationBanner'
1010

1111
<DeprecationBanner replacementUrl={'/components/avatar-pair/react/latest'} />

docs/content/AvatarStack.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source: https://github.com/primer/react/blob/main/src/AvatarStack
77
storybook: '/react/storybook?path=/story/components-avatarstack--default'
88
---
99

10-
import data from '../../src/AvatarStack/AvatarStack.docs.json'
10+
import data from '../../packages/react/src/AvatarStack/AvatarStack.docs.json'
1111
import {AvatarStack} from '@primer/react'
1212
import DeprecationBanner from '../components/DeprecationBanner'
1313

docs/content/Box.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: A low-level utility component that accepts styles to enable custom
66
source: https://github.com/primer/react/blob/main/src/Box.tsx
77
---
88

9-
import data from '../../src/Box/Box.docs.json'
9+
import data from '../../packages/react/src/Box/Box.docs.json'
1010
import DeprecationBanner from '../components/DeprecationBanner'
1111

1212
<DeprecationBanner replacementUrl={'/components/box/react/latest'} />

docs/content/BranchName.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ status: Alpha
55
source: https://github.com/primer/react/blob/main/src/BranchName/BranchName.tsx
66
---
77

8-
import data from '../../src/BranchName/BranchName.docs.json'
8+
import data from '../../packages/react/src/BranchName/BranchName.docs.json'
99
import DeprecationBanner from '../components/DeprecationBanner'
1010

1111
<DeprecationBanner replacementUrl={'/components/branch-name/react/latest'} />

docs/content/Breadcrumbs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: Use breadcrumbs to show navigational context on pages that are many
66
source: https://github.com/primer/react/blob/main/src/Breadcrumbs/Breadcrumbs.tsx
77
---
88

9-
import data from '../../src/Breadcrumbs/Breadcrumbs.docs.json'
9+
import data from '../../packages/react/src/Breadcrumbs/Breadcrumbs.docs.json'
1010
import DeprecationBanner from '../components/DeprecationBanner'
1111

1212
<DeprecationBanner replacementUrl={'/components/breadcrumbs/react/latest'} />

docs/content/Button.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ storybook: '/react/storybook?path=/story/components-button--playground'
77
description: Use button for the main actions on a page or form.
88
---
99

10-
import data from '../../src/Button/Button.docs.json'
10+
import data from '../../packages/react/src/Button/Button.docs.json'
1111
import DeprecationBanner from '../components/DeprecationBanner'
1212

1313
<DeprecationBanner replacementUrl={'/components/button/react/latest'} />

docs/content/ButtonGroup.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ source: https://github.com/primer/react/tree/main/src/ButtonGroup
66
storybook: '/react/storybook?path=/story/components-buttongroup--default'
77
---
88

9-
import data from '../../src/ButtonGroup/ButtonGroup.docs.json'
9+
import data from '../../packages/react/src/ButtonGroup/ButtonGroup.docs.json'
1010
import DeprecationBanner from '../components/DeprecationBanner'
1111

1212
<DeprecationBanner replacementUrl={'/components/button-group/react/latest'} />

docs/content/Checkbox.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ storybook: '/react/storybook?path=/story/components-forms-checkbox'
77
componentId: checkbox
88
---
99

10-
import data from '../../src/Checkbox/Checkbox.docs.json'
10+
import data from '../../packages/react/src/Checkbox/Checkbox.docs.json'
1111
import DeprecationBanner from '../components/DeprecationBanner'
1212

1313
<DeprecationBanner replacementUrl={'/components/checkbox/react/latest'} />

docs/content/CheckboxGroup.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source: https://github.com/primer/react/blob/main/src/CheckboxGroup/CheckboxGrou
77
storybook: '/react/storybook/?path=/story/components-forms-checkboxgroup-examples'
88
---
99

10-
import data from '../../src/CheckboxGroup/CheckboxGroup.docs.json'
10+
import data from '../../packages/react/src/CheckboxGroup/CheckboxGroup.docs.json'
1111

1212
import {CheckboxGroup, Checkbox, Box} from '@primer/components'
1313
import {CheckIcon, XIcon, AlertIcon} from '@primer/octicons-react'

docs/content/CircleBadge.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ status: Alpha
55
source: https://github.com/primer/react/blob/main/src/CircleBadge
66
---
77

8-
import data from '../../src/CircleBadge/CircleBadge.docs.json'
8+
import data from '../../packages/react/src/CircleBadge/CircleBadge.docs.json'
99
import DeprecationBanner from '../components/DeprecationBanner'
1010

1111
<DeprecationBanner replacementUrl={'/components/circle-badge/react/latest'} />

docs/content/CircleOcticon.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ status: Alpha
55
source: https://github.com/primer/react/blob/main/src/CircleOcticon
66
---
77

8-
import data from '../../src/CircleOcticon/CircleOcticon.docs.json'
8+
import data from '../../packages/react/src/CircleOcticon/CircleOcticon.docs.json'
99

1010
CircleOcticon renders any Octicon with a circle background. CircleOcticons are most commonly used to represent the status of a pull request in the comment timeline.
1111

0 commit comments

Comments
 (0)