Skip to content

Commit e7db8e5

Browse files
committed
build: convert repo from npm to pnpm
- pnpm import package-lock.json -> pnpm-lock.yaml; remove package-lock.json - add packageManager: pnpm@11.15.1 to package.json - pnpm-workspace.yaml allowBuilds for tree-sitter, tree-sitter-cli, esbuild (pnpm blocks dependency install scripts by default) - ci.yml + release.yml: pnpm/action-setup@v6, cache: pnpm, pnpm install --frozen-lockfile, pnpm run - version script: npm install --package-lock-only -> pnpm install --lockfile-only - README/tools contributor commands npm/npx -> pnpm - ignore package-lock.json/yarn.lock
1 parent 7fb2038 commit e7db8e5

10 files changed

Lines changed: 2451 additions & 4175 deletions

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ jobs:
1111
os: [ubuntu-latest, macos-latest]
1212
steps:
1313
- uses: actions/checkout@v6
14+
- uses: pnpm/action-setup@v6
1415
- uses: actions/setup-node@v6
1516
with:
1617
node-version: 22
17-
- run: npm install
18-
- run: npm run build
18+
cache: pnpm
19+
- run: pnpm install --frozen-lockfile
20+
- run: pnpm run build
1921
# Fixtures are fetched from marko-js/htmljs-parser with degit; the
2022
# parser the tests compare against is the published htmljs-parser.
21-
- run: npm test
23+
- run: pnpm test
2224

2325
prebuild:
2426
runs-on: ${{ matrix.os }}
@@ -38,17 +40,19 @@ jobs:
3840
]
3941
steps:
4042
- uses: actions/checkout@v6
43+
- uses: pnpm/action-setup@v6
4144
- uses: actions/setup-node@v6
4245
with:
4346
node-version: 22
47+
cache: pnpm
4448
# Skip the package's node-gyp-build install script — prebuildify does the
4549
# real build, so the install-time compile is redundant.
46-
- run: npm install --ignore-scripts
47-
- run: npm run prebuild
50+
- run: pnpm install --frozen-lockfile --ignore-scripts
51+
- run: pnpm run prebuild
4852
# macOS runners are arm64; cross-build the Intel (x64) prebuild too so we
4953
# don't need an Intel runner (N-API addons cross-compile cleanly).
5054
- if: runner.os == 'macOS'
51-
run: npm run prebuild -- --arch x64
55+
run: pnpm run prebuild --arch x64
5256
- uses: actions/upload-artifact@v7
5357
with:
5458
name: prebuild-${{ matrix.os }}
@@ -58,13 +62,15 @@ jobs:
5862
runs-on: ubuntu-latest
5963
steps:
6064
- uses: actions/checkout@v6
65+
- uses: pnpm/action-setup@v6
6166
- uses: actions/setup-node@v6
6267
with:
6368
node-version: 22
69+
cache: pnpm
6470
# tree-sitter-cli downloads the wasi-sdk toolchain automatically.
65-
- run: npm install
66-
- run: npm run build:wasm
67-
- run: npm run test:wasm
71+
- run: pnpm install --frozen-lockfile
72+
- run: pnpm run build:wasm
73+
- run: pnpm run test:wasm
6874
- uses: actions/upload-artifact@v7
6975
with:
7076
name: tree-sitter-marko-wasm

.github/workflows/release.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ name: Release
44
#
55
# Every push to main runs the `release` job (changesets/action):
66
# - if .changeset/*.md files are pending, it opens/updates a "[ci] release"
7-
# PR that runs `npm run version` (bumps package.json + tree-sitter.json,
7+
# PR that runs `pnpm run version` (bumps package.json + tree-sitter.json,
88
# writes CHANGELOG.md, consumes the changesets);
99
# - when that PR is merged (no changesets left), it runs the publish command
10-
# `npm run release:tag`, which tags the release and sets the action's
10+
# `pnpm run release:tag`, which tags the release and sets the action's
1111
# `published` output to true.
1212
#
1313
# The prebuild/wasm/publish jobs are gated on `published`, so they only run on
@@ -38,15 +38,17 @@ jobs:
3838
- uses: actions/checkout@v6
3939
with:
4040
fetch-depth: 0
41+
- uses: pnpm/action-setup@v6
4142
- uses: actions/setup-node@v6
4243
with:
4344
node-version: 22
44-
- run: npm install
45+
cache: pnpm
46+
- run: pnpm install --frozen-lockfile
4547
- id: changesets
4648
uses: changesets/action@v1
4749
with:
48-
version: npm run version
49-
publish: npm run release:tag
50+
version: pnpm run version
51+
publish: pnpm run release:tag
5052
commit: "[ci] release"
5153
title: "[ci] release"
5254
env:
@@ -72,17 +74,19 @@ jobs:
7274
]
7375
steps:
7476
- uses: actions/checkout@v6
77+
- uses: pnpm/action-setup@v6
7578
- uses: actions/setup-node@v6
7679
with:
7780
node-version: 22
81+
cache: pnpm
7882
# Skip the package's node-gyp-build install script — prebuildify does the
7983
# real build, so the install-time compile is redundant.
80-
- run: npm install --ignore-scripts
81-
- run: npm run prebuild
84+
- run: pnpm install --frozen-lockfile --ignore-scripts
85+
- run: pnpm run prebuild
8286
# macOS runners are arm64; cross-build the Intel (x64) prebuild too so we
8387
# don't need an Intel runner (N-API addons cross-compile cleanly).
8488
- if: runner.os == 'macOS'
85-
run: npm run prebuild -- --arch x64
89+
run: pnpm run prebuild --arch x64
8690
- uses: actions/upload-artifact@v7
8791
with:
8892
name: prebuild-${{ matrix.os }}
@@ -95,13 +99,15 @@ jobs:
9599
runs-on: ubuntu-latest
96100
steps:
97101
- uses: actions/checkout@v6
102+
- uses: pnpm/action-setup@v6
98103
- uses: actions/setup-node@v6
99104
with:
100105
node-version: 22
106+
cache: pnpm
101107
# tree-sitter-cli downloads the wasi-sdk toolchain automatically.
102-
- run: npm install
103-
- run: npm run build:wasm
104-
- run: npm run test:wasm
108+
- run: pnpm install --frozen-lockfile
109+
- run: pnpm run build:wasm
110+
- run: pnpm run test:wasm
105111
- uses: actions/upload-artifact@v7
106112
with:
107113
name: wasm
@@ -113,16 +119,18 @@ jobs:
113119
runs-on: ubuntu-latest
114120
steps:
115121
- uses: actions/checkout@v6
122+
- uses: pnpm/action-setup@v6
116123
- uses: actions/setup-node@v6
117124
with:
118125
node-version: 22
126+
cache: pnpm
119127
registry-url: https://registry.npmjs.org
120128
# npm >= 11.5.1 is required for OIDC trusted publishing.
121129
- run: npm install -g npm@latest
122-
- run: npm install
130+
- run: pnpm install --frozen-lockfile
123131
# Refresh generated sources (src/parser.c etc.) so the published tree
124132
# matches grammar.js exactly.
125-
- run: npm run generate
133+
- run: pnpm run generate
126134
# Gather every platform's prebuild back into prebuilds/ and the wasm
127135
# build to the package root, matching package.json "files".
128136
- uses: actions/download-artifact@v8
@@ -141,6 +149,6 @@ jobs:
141149
# so this is a no-op unless the version actually changed. Authenticated via
142150
# npm trusted publishing (OIDC); provenance is enabled via the env var. No
143151
# token required.
144-
- run: npm run release:publish
152+
- run: pnpm run release:publish
145153
env:
146154
NPM_CONFIG_PROVENANCE: "true"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ prebuilds
55
*.dylib
66
*.wasm
77
.vscode
8+
package-lock.json
9+
yarn.lock

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ parser.setLanguage(Marko);
4040
Building from a checkout:
4141

4242
```sh
43-
npm install
44-
npm run build # tree-sitter generate && node-gyp rebuild
45-
npm run build:wasm # tree-sitter-marko.wasm (the CLI fetches wasi-sdk itself)
43+
pnpm install
44+
pnpm run build # tree-sitter generate && node-gyp rebuild
45+
pnpm run build:wasm # tree-sitter-marko.wasm (the CLI fetches wasi-sdk itself)
4646
```
4747

4848
For editors, the grammar ships ready-to-use queries: `queries/highlights.scm`
@@ -61,9 +61,9 @@ in the host tool like any other language.
6161
From this directory:
6262

6363
```sh
64-
npx tree-sitter playground # interactive tree in the browser
65-
npx tree-sitter parse file.marko # print the syntax tree
66-
npx tree-sitter highlight file.marko # ANSI highlighting (--html for a page)
64+
pnpm exec tree-sitter playground # interactive tree in the browser
65+
pnpm exec tree-sitter parse file.marko # print the syntax tree
66+
pnpm exec tree-sitter highlight file.marko # ANSI highlighting (--html for a page)
6767
```
6868

6969
`highlight` resolves the injected languages through the CLI config: run
@@ -82,7 +82,7 @@ and start treesitter for the filetype:
8282
```sh
8383
# from this directory
8484
mkdir -p ~/.local/share/nvim/site/parser ~/.local/share/nvim/site/queries
85-
npx tree-sitter build -o ~/.local/share/nvim/site/parser/marko.so
85+
pnpm exec tree-sitter build -o ~/.local/share/nvim/site/parser/marko.so
8686
cp -R queries ~/.local/share/nvim/site/queries/marko
8787
```
8888

@@ -262,7 +262,7 @@ split without lookahead the scanner doesn't have.
262262

263263
Marko's parser is [htmljs-parser](https://github.com/marko-js/htmljs-parser);
264264
this grammar's external scanner reimplements its state machine, and the test
265-
suite (`npm test`, Node 22) asserts the tree reproduces the parser's event
265+
suite (`pnpm test`, Node 22) asserts the tree reproduces the parser's event
266266
stream with byte-precise ranges across the parser's full fixture suite, plus
267267
thousands of templates from the Marko ecosystem during development.
268268

0 commit comments

Comments
 (0)