Skip to content

Commit 965f608

Browse files
authored
build: restructure repo as pnpm workspace monorepo (#262)
1 parent dc61c56 commit 965f608

638 files changed

Lines changed: 6972 additions & 824 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.

.github/workflows/chromatic.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ jobs:
1919
version: 10.20.0
2020
- uses: actions/setup-node@v4
2121
with:
22-
node-version: '20.19'
22+
node-version: '22'
2323
cache: pnpm
2424
- name: Install dependencies
2525
run: pnpm install --frozen-lockfile
26+
- name: Build design tokens
27+
run: pnpm build-tokens
2628
- name: Run Chromatic
2729
uses: chromaui/action@latest
2830
with:
2931
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
3032
onlyChanged: true # Required option to enable TurboSnap
33+
workingDir: packages/components

.github/workflows/pull-request.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ permissions:
1717
contents: 'read'
1818
packages: 'read'
1919
repository-projects: 'read'
20-
env:
21-
GH_PACKAGES_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2320

2421
jobs:
2522
lint-js:
@@ -32,10 +29,8 @@ jobs:
3229
version: 10.20.0
3330
- uses: actions/setup-node@v4
3431
with:
35-
node-version: '20.19'
32+
node-version: '22'
3633
cache: pnpm
37-
- name: Set up .npmrc
38-
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
3934
- name: Install dependencies
4035
run: pnpm install --frozen-lockfile
4136
- name: Lint
@@ -50,10 +45,8 @@ jobs:
5045
version: 10.20.0
5146
- uses: actions/setup-node@v4
5247
with:
53-
node-version: '20.19'
48+
node-version: '22'
5449
cache: pnpm
55-
- name: Set up .npmrc
56-
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
5750
- name: Install dependencies
5851
run: pnpm install --frozen-lockfile
5952
- name: Build
@@ -68,7 +61,7 @@ jobs:
6861
version: 10.20.0
6962
- uses: actions/setup-node@v4
7063
with:
71-
node-version: '20.19'
64+
node-version: '22'
7265
cache: pnpm
7366
- name: Install dependencies
7467
run: pnpm install --frozen-lockfile
@@ -84,7 +77,7 @@ jobs:
8477
version: 10.20.0
8578
- uses: actions/setup-node@v4
8679
with:
87-
node-version: '20.19'
80+
node-version: '22'
8881
cache: pnpm
8982
- name: Install dependencies
9083
run: pnpm install --frozen-lockfile
@@ -103,12 +96,15 @@ jobs:
10396
version: 10.20.0
10497
- uses: actions/setup-node@v4
10598
with:
106-
node-version: '20.19'
99+
node-version: '22'
107100
cache: pnpm
108101
- name: Install dependencies
109102
run: pnpm install --frozen-lockfile
103+
- name: Build design tokens
104+
run: pnpm build-tokens
110105
- name: Run Chromatic
111106
uses: chromaui/action@latest
112107
with:
113108
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
114109
onlyChanged: true # Required option to enable TurboSnap
110+
workingDir: packages/components

.github/workflows/semantic-release.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Release
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'Release tag to publish (e.g. v7.8.0). Defaults to the committed package versions.'
8+
required: false
9+
type: string
510
release:
611
types: [published]
712

@@ -11,7 +16,7 @@ permissions:
1116

1217
jobs:
1318
release:
14-
name: Release Package
19+
name: Release Packages
1520
runs-on: ubuntu-latest
1621
steps:
1722
- uses: actions/checkout@v6
@@ -29,16 +34,35 @@ jobs:
2934
- name: install dependencies
3035
run: pnpm install --frozen-lockfile
3136

37+
# Both packages release in lockstep: the git tag is the single source
38+
# of truth for the version. Setting versions before publish also makes
39+
# pnpm rewrite the workspace:^ dependency to ^<version>.
40+
- name: set package versions from release tag
41+
run: |
42+
TAG="${{ github.event.release.tag_name || inputs.tag }}"
43+
if [[ -n "$TAG" ]]; then
44+
VERSION="${TAG#v}"
45+
echo "Setting all package versions to $VERSION"
46+
pnpm -r exec npm pkg set version="$VERSION"
47+
else
48+
echo "No tag available; publishing with committed package versions"
49+
fi
50+
3251
- name: test
3352
run: pnpm test
3453

3554
- name: build
3655
run: pnpm build
3756

57+
# pnpm (not npm) must do the publishing: only pnpm rewrites the
58+
# workspace:^ protocol to a real semver range in the published
59+
# manifests. -r publishes in dependency order (design-tokens first)
60+
# and skips the private workspace root. --no-git-checks is required
61+
# because release events check out a detached tag.
3862
- name: Publish
3963
run: |
4064
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
41-
npm publish --ignore-scripts --tag beta --access public
65+
pnpm publish -r --access public --tag beta --no-git-checks --ignore-scripts
4266
else
43-
npm publish --ignore-scripts --access public
67+
pnpm publish -r --access public --no-git-checks --ignore-scripts
4468
fi

.gitignore

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ node_modules
55
dist
66

77
# testing
8-
/coverage
8+
coverage
99

1010
# production
11-
/coverage
12-
/dist
13-
/build
14-
/storybook-static
11+
build
12+
storybook-static
1513

1614
# IDEs
1715
.vscode

.releaserc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
22
"branches": ["main", { "name": "beta", "prerelease": true }],
33
"plugins": [
4-
"@semantic-release/npm",
5-
"@semantic-release/github",
6-
"@semantic-release/release-notes-generator",
74
["@semantic-release/commit-analyzer", {
85
"preset": "angular",
96
"releaseRules": [
@@ -17,6 +14,15 @@
1714
{ "type": "feat", "release": "minor" },
1815
{ "type": "fix", "release": "patch" }
1916
]
20-
}]
17+
}],
18+
"@semantic-release/release-notes-generator",
19+
["@semantic-release/exec", {
20+
"prepareCmd": "pnpm -r exec npm pkg set version=${nextRelease.version}"
21+
}],
22+
["@semantic-release/git", {
23+
"assets": ["packages/components/package.json", "packages/design-tokens/package.json"],
24+
"message": "chore(release): ${nextRelease.version} [skip ci]"
25+
}],
26+
"@semantic-release/github"
2127
]
2228
}

.storybook/main.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

AGENTS.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
# AGENTS.md
22

3+
## Repository layout
4+
5+
- This is a pnpm workspace monorepo with two published packages:
6+
- `packages/components``@hyphen/hyphen-components`, the React component library.
7+
- `packages/design-tokens``@hyphen/hyphen-design-tokens`, the design token source (token JSON in `tokens/`, icon/logo SVGs in `assets/`) and its Style Dictionary build.
8+
- Components consume the tokens package via a `workspace:^` dependency; the tokens `build/` output must exist before component tests or Storybook run. The root scripts handle this ordering — prefer them over per-package scripts.
9+
- Both packages share one version and are published together by the Release workflow (version comes from the GitHub release tag).
10+
311
## Testing instructions
412

513
- Find the CI plan in the .github/workflows folder.
6-
- From the package root you can just call `pnpm test`. The commit should pass all tests before you merge.
14+
- From the repo root you can just call `pnpm test` (it builds the design tokens first, then runs every package's tests). The commit should pass all tests before you merge.
715
- Fix any test or type errors until the whole suite is green.
816
- Add or update tests for the code you change, even if nobody asked.
917

1018
## PR instructions
1119

12-
- Always run `pnpm lint` and `pnpm test` before committing.
20+
- Always run `pnpm lint` and `pnpm test` from the repo root before committing.
1321

1422
## Code Review Checklist
1523

README.md

Lines changed: 35 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,56 @@
11
<p align="center">
2-
<a href="https://hyphen.ai" rel="noopener" target="_blank"><img width="150" src="public/images/logo.png" alt="Hyphen logo"></a></p>
2+
<a href="https://hyphen.ai" rel="noopener" target="_blank"><img width="150" src="packages/components/public/images/logo.png" alt="Hyphen logo"></a></p>
33
</p>
44

5-
<h1 align="center" style="border-bottom: none;">Hyphen Component Library</h1>
5+
<h1 align="center" style="border-bottom: none;">Hyphen Design System</h1>
66
<h3 align="center">
77

8-
A [React](https://reactjs.org/) component library to power all Hyphen UI
8+
The monorepo for Hyphen's design system packages
99

1010
</h3>
1111

12-
## Quick Start
12+
## Packages
1313

14-
### 1. Install
14+
| Package | Description |
15+
| --- | --- |
16+
| [`@hyphen/hyphen-components`](packages/components) | A [React](https://reactjs.org/) component library to power all Hyphen UI |
17+
| [`@hyphen/hyphen-design-tokens`](packages/design-tokens) | Design tokens (color, spacing, typography, icons, logos) that power all Hyphen UIs |
1518

16-
`pnpm add @hyphen/hyphen-components`
17-
18-
### 2. Import Global CSS
19+
Both packages are versioned and released together: one GitHub release
20+
publishes both to npm with the same version.
1921

20-
```jsx
21-
import '@hyphen/hyphen-components/dist/css/utilities.css'; // Utility classes -- REQUIRED
22-
import '@hyphen/hyphen-components/dist/css/variables.css'; // CSS Variables -- REQUIRED
23-
import '@hyphen/hyphen-components/dist/css/index.css'; // Component CSS -- REQUIRED
24-
import '@hyphen/hyphen-components/dist/css/fonts.css'; // Included Font files -- OPTIONAL BUT ENCOURAGED
25-
```
22+
## Quick Start (consumers)
2623

27-
We recommend importing our global reset in order to maintain a consistent
28-
look of all components across applications.
24+
`pnpm add @hyphen/hyphen-components`
2925

30-
```jsx
31-
import '@hyphen/hyphen-components/dist/css/reset.css' // A Basic CSS Reset -- OPTIONAL BUT ENCOURAGED.
32-
```
26+
See the [components README](packages/components/README.md) for usage,
27+
global CSS imports, and documentation links.
3328

34-
### 3. Usage
29+
Design tokens can also be consumed directly on other platforms:
30+
`pnpm add @hyphen/hyphen-design-tokens` — see the
31+
[design tokens README](packages/design-tokens/README.md).
3532

36-
```jsx
37-
import React from 'react';
38-
import ReactDOM from 'react-dom';
39-
import { Box } from '@hyphen/hyphen-components';
33+
## Development
4034

41-
function App() {
42-
return <Box>Hello World</Box>;
43-
}
35+
This is a [pnpm workspace](https://pnpm.io/workspaces). All commands run
36+
from the repo root:
4437

45-
ReactDOM.render(<App />, document.querySelector('#app'));
38+
```sh
39+
pnpm install # install all workspace dependencies
40+
pnpm build # build design tokens, then components
41+
pnpm test # build tokens, then run all test suites
42+
pnpm lint # lint all packages
43+
pnpm storybook # run the component Storybook locally
4644
```
4745

48-
## Documentation
49-
50-
[SEE FULL DOCS HERE](https://ux.hyphen.ai)
51-
52-
## Contributing
53-
54-
Issues and PRs welcome! See [HERE](./CONTRIBUTING.md) for our Contribution Guide.
55-
56-
## Raising an Issue
57-
58-
When raising an issue:
59-
60-
* Make sure the issue hasn't been raised yet.
61-
* Tag issue accordingly using your best judgement. Do NOT create new tags. If you feel a new one is needed, raise it in your issue.
62-
* If your issue is a bug, include **screenshots** or animated GIFs in your issue whenever needed (if issue is visual in nature).
63-
* If your issue is a bug, include steps to reproduce, or link to reproducible issue, e.g.: Code Sandbox or similar. Please also provide any additional details including device, OS, browser, browser version etc.
64-
65-
[Issues can be raised here](https://github.com/hyphen/hyphen-components/issues).
46+
Changing a color, icon, or any other token is now a normal PR to this
47+
repo: edit the sources in `packages/design-tokens` (token JSON in
48+
`tokens/`, icon SVGs in `assets/icons`) and the same PR can update the
49+
components that use them.
6650

67-
## License
51+
## Releasing
6852

69-
This project is licensed under the terms of the
70-
[MIT license](./LICENSE).
53+
Releases are automated with [semantic-release](https://github.com/semantic-release/semantic-release)
54+
from conventional commit messages. When a GitHub release is published,
55+
the Release workflow stamps the tag's version into both packages and
56+
publishes them to npm in dependency order.

0 commit comments

Comments
 (0)