Skip to content

Commit acf253b

Browse files
committed
chore: switch to pnpm monorepo
1 parent 734e290 commit acf253b

31 files changed

+255
-146
lines changed

.github/workflows/release.yml

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
if: ${{ !contains(github.head_ref, 'all-contributors') }}
2020
name: Svelte ${{ matrix.svelte }}, Node ${{ matrix.node }}, ${{ matrix.check }}
2121
runs-on: ubuntu-latest
22+
needs: [build]
2223

2324
# enable OIDC for codecov uploads
2425
permissions:
@@ -41,24 +42,35 @@ jobs:
4142
- { svelte: '5', node: '22', check: 'lint' }
4243
- { svelte: '5', node: '22', check: 'test:examples' }
4344
# Run type checks in latest applicable Node
44-
- { svelte: '3', node: '20', check: 'types:legacy' }
45-
- { svelte: '4', node: '22', check: 'types:legacy' }
46-
- { svelte: '5', node: '22', check: 'types' }
45+
- { svelte: '3', node: '20', check: 'test:types:legacy' }
46+
- { svelte: '4', node: '22', check: 'test:types:legacy' }
47+
- { svelte: '5', node: '22', check: 'test:types' }
4748

4849
steps:
4950
- name: ⬇️ Checkout repo
5051
uses: actions/checkout@v4
5152

53+
- name: 🧱 Setup pnpm
54+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
55+
with:
56+
standalone: ${{ matrix.node == '16' }}
57+
5258
- name: ⎔ Setup node
5359
uses: actions/setup-node@v4
5460
with:
5561
node-version: ${{ matrix.node }}
5662

5763
- name: 📥 Download deps
58-
run: npm run install:${{ matrix.svelte }}
64+
run: pnpm run install:${{ matrix.svelte }}
65+
66+
- name: 📥 Download types build
67+
uses: actions/download-artifact@v4
68+
with:
69+
name: build
70+
path: packages/svelte
5971

6072
- name: ▶️ Run ${{ matrix.check }}
61-
run: npm run ${{ matrix.check }}
73+
run: pnpm run ${{ matrix.check }}
6274

6375
- name: ⬆️ Upload coverage report
6476
if: ${{ startsWith(matrix.check, 'test:') }}
@@ -73,22 +85,27 @@ jobs:
7385
- name: ⬇️ Checkout repo
7486
uses: actions/checkout@v4
7587

88+
- name: 🧱 Setup pnpm
89+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
90+
7691
- name: ⎔ Setup node
7792
uses: actions/setup-node@v4
7893
with:
7994
node-version: 22
8095

8196
- name: 📥 Download deps
82-
run: npm install
97+
run: pnpm install
8398

84-
- name: 🏗️ Build types
85-
run: npm run build
99+
- name: 🏗️ Build types and docs
100+
run: pnpm run build
86101

87-
- name: ⬆️ Upload types build
102+
- name: ⬆️ Upload build
88103
uses: actions/upload-artifact@v4
89104
with:
90-
name: types
91-
path: types
105+
name: build
106+
path: |
107+
packages/svelte/README.md
108+
packages/svelte/types
92109
93110
release:
94111
needs: [main, build]
@@ -105,11 +122,11 @@ jobs:
105122
with:
106123
node-version: 22
107124

108-
- name: 📥 Downloads types build
125+
- name: 📥 Download types build
109126
uses: actions/download-artifact@v4
110127
with:
111-
name: types
112-
path: types
128+
name: build
129+
path: packages/svelte
113130

114131
- name: 🚀 Release
115132
uses: cycjimmy/semantic-release-action@v4

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ yarn.lock
1313

1414
# generated typing output
1515
types
16+
*.tsbuildinfo
17+
18+
# copied documentation
19+
packages/svelte/README.md

CONTRIBUTING.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,40 @@ If you would like to preview the release from a given branch, and...
2323
...you can preview the next release version and changelog using:
2424

2525
```shell
26-
npm run preview-release
26+
pnpm run preview-release
2727
```
2828

2929
## Development setup
3030

31+
This repository uses `pnpm` as its package manager. See the `pnpm` [installation guide](https://pnpm.io/installation) to set it up through whatever method you prefer.
32+
3133
After cloning the repository, use the `setup` script to install dependencies and run all checks:
3234

3335
```shell
34-
npm run setup
36+
pnpm run setup
3537
```
3638

3739
### Lint and format
3840

3941
Run auto-formatting to ensure any changes adhere to the code style of the repository:
4042

4143
```shell
42-
npm run format
44+
pnpm run format
4345
```
4446

4547
To run lint and format checks without making any changes:
4648

4749
```shell
48-
npm run lint
50+
pnpm run lint
4951
```
5052

5153
### Test
5254

5355
Run unit tests once or in watch mode:
5456

5557
```shell
56-
npm test
57-
npm run test:watch
58+
pnpm test
59+
pnpm run test:watch
5860
```
5961

6062
### Using different versions of Svelte
@@ -63,34 +65,34 @@ Use the provided script to set up your environment for different versions of Sve
6365

6466
```shell
6567
# Svelte 5
66-
npm run install:5
67-
npm run all
68+
pnpm run install:5
69+
pnpm run all
6870

6971
# Svelte 4
70-
npm run install:4
71-
npm run all:legacy
72+
pnpm run install:4
73+
pnpm run all:legacy
7274

7375
# Svelte 3
74-
npm run install:3
75-
npm run all:legacy
76+
pnpm run install:3
77+
pnpm run all:legacy
7678
```
7779

7880
### Docs
7981

8082
Use the `docs` script to ensure the README's table of contents is up to date:
8183

8284
```shell
83-
npm run docs
85+
pnpm run docs
8486
```
8587

8688
Use `contributors:add` to add a contributor to the README:
8789

8890
```shell
89-
npm run contributors:add
91+
pnpm run contributors:add
9092
```
9193

9294
Use `contributors:generate` to ensure the README's contributor list is up to date:
9395

9496
```shell
95-
npm run contributors:generate
97+
pnpm run contributors:generate
9698
```

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default tseslint.config(
3737
},
3838
{
3939
name: 'ignores',
40-
ignores: ['coverage', 'types'],
40+
ignores: ['**/coverage/**', '**/types/**'],
4141
},
4242
{
4343
name: 'simple-import-sort',

jest.config.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ export default {
1717
injectGlobals: true,
1818
moduleNameMapper: {
1919
'^vitest$': '<rootDir>/tests/_jest-vitest-alias.js',
20-
[String.raw`^@testing-library\/svelte$`]: '<rootDir>/src/index.js',
2120
},
2221
resetMocks: true,
2322
restoreMocks: true,
24-
collectCoverageFrom: ['<rootDir>/src/**/*'],
23+
collectCoverageFrom: ['<rootDir>/packages/*/src/**/*'],
2524
coveragePathIgnorePatterns: [
26-
'<rootDir>/src/vite.js',
27-
'<rootDir>/src/vitest.js',
25+
'<rootDir>/packages/svelte/src/vite.js',
26+
'<rootDir>/packages/svelte/src/vitest.js',
2827
],
2928
}

package.json

Lines changed: 18 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,43 @@
11
{
2-
"name": "@testing-library/svelte",
3-
"version": "0.0.0-semantically-released",
4-
"description": "Simple and complete Svelte testing utilities that encourage good testing practices.",
5-
"main": "src/index.js",
6-
"exports": {
7-
".": {
8-
"types": "./types/index.d.ts",
9-
"default": "./src/index.js"
10-
},
11-
"./svelte5": {
12-
"types": "./types/index.d.ts",
13-
"default": "./src/index.js"
14-
},
15-
"./vitest": {
16-
"types": "./types/vitest.d.ts",
17-
"default": "./src/vitest.js"
18-
},
19-
"./vite": {
20-
"types": "./types/vite.d.ts",
21-
"default": "./src/vite.js"
22-
}
23-
},
2+
"name": "@testing-library/svelte-repo",
3+
"private": true,
244
"type": "module",
25-
"types": "types/index.d.ts",
265
"license": "MIT",
27-
"homepage": "https://github.com/testing-library/svelte-testing-library#readme",
28-
"repository": {
29-
"type": "git",
30-
"url": "git+https://github.com/testing-library/svelte-testing-library.git"
31-
},
32-
"bugs": {
33-
"url": "https://github.com/testing-library/svelte-testing-library/issues"
34-
},
35-
"engines": {
36-
"node": ">= 10"
37-
},
38-
"keywords": [
39-
"testing",
40-
"svelte",
41-
"ui",
42-
"dom",
43-
"jsdom",
44-
"unit",
45-
"integration",
46-
"functional",
47-
"end-to-end",
48-
"e2e"
49-
],
50-
"files": [
51-
"src",
52-
"types"
53-
],
546
"scripts": {
55-
"all": "npm-run-all contributors:generate docs format types build test:vitest:* test:jest test:examples",
56-
"all:legacy": "npm-run-all types:legacy test:vitest:* test:jest",
57-
"docs": "remark --output --use remark-toc --use remark-code-import --use unified-prettier README.md examples",
7+
"all": "pnpm contributors:generate && pnpm build && pnpm format && pnpm test:all",
8+
"all:legacy": "pnpm build:types && pnpm test:all:legacy",
9+
"docs": "",
5810
"lint": "prettier . --check && eslint .",
5911
"format": "prettier . --write && eslint . --fix",
60-
"setup": "npm run install:5 && npm run all",
12+
"setup": "pnpm install:5 && pnpm all",
6113
"test": "vitest run --coverage",
6214
"test:watch": "vitest",
6315
"test:vitest:jsdom": "vitest run tests --coverage --environment jsdom",
6416
"test:vitest:happy-dom": "vitest run tests --coverage --environment happy-dom",
65-
"test:jest": "npx --node-options=\"--experimental-vm-modules --no-warnings\" jest --coverage",
17+
"test:jest": "NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" jest --coverage",
6618
"test:examples": "vitest run examples --coverage",
67-
"types": "svelte-check",
68-
"types:legacy": "svelte-check --tsconfig tsconfig.legacy.json",
69-
"build": "tsc -p tsconfig.build.json && cp src/component-types.d.ts types",
19+
"test:types": "svelte-check --tsconfig=tests/tsconfig.json",
20+
"test:types:legacy": "svelte-check --tsconfig=tests/tsconfig.legacy.json",
21+
"test:all": "pnpm test:types && pnpm test:vitest:jsdom && pnpm test:vitest:happy-dom && pnpm test:jest && pnpm test:examples",
22+
"test:all:legacy": "pnpm test:types:legacy && pnpm test:vitest:jsdom && pnpm test:vitest:happy-dom && pnpm test:jest",
23+
"build": "pnpm build:types && pnpm build:docs",
24+
"build:types": "tsc --build && cp packages/svelte/src/component-types.d.ts packages/svelte/types",
25+
"build:docs": "remark --output --use remark-toc --use remark-code-import --use unified-prettier README.md examples && cp -f README.md packages/svelte",
7026
"contributors:add": "all-contributors add",
7127
"contributors:generate": "all-contributors generate",
7228
"preview-release": "./scripts/preview-release",
7329
"install:3": "./scripts/install-dependencies 3",
7430
"install:4": "./scripts/install-dependencies 4",
7531
"install:5": "./scripts/install-dependencies 5"
7632
},
77-
"peerDependencies": {
78-
"svelte": "^3 || ^4 || ^5 || ^5.0.0-next.0",
79-
"vite": "*",
80-
"vitest": "*"
81-
},
82-
"peerDependenciesMeta": {
83-
"vite": {
84-
"optional": true
85-
},
86-
"vitest": {
87-
"optional": true
88-
}
89-
},
9033
"dependencies": {
91-
"@testing-library/dom": "9.x.x || 10.x.x"
34+
"@testing-library/svelte": "workspace:*"
9235
},
9336
"devDependencies": {
9437
"@eslint/js": "^9.26.0",
9538
"@jest/globals": "^29.7.0",
9639
"@sveltejs/vite-plugin-svelte": "^5.0.3",
40+
"@testing-library/dom": "9.x.x || 10.x.x",
9741
"@testing-library/jest-dom": "^6.6.3",
9842
"@testing-library/user-event": "^14.6.1",
9943
"@vitest/coverage-v8": "^3.1.3",
@@ -128,5 +72,6 @@
12872
"unified-prettier": "^2.0.1",
12973
"vite": "^6.3.5",
13074
"vitest": "^3.1.3"
131-
}
75+
},
76+
"packageManager": "[email protected]+sha512.bf049efe995b28f527fd2b41ae0474ce29186f7edcb3bf545087bd61fbbebb2bf75362d1307fda09c2d288e1e499787ac12d4fcb617a974718a6051f2eee741c"
13277
}

0 commit comments

Comments
 (0)