Skip to content

Commit 119aaea

Browse files
authored
Merge pull request #346 from tharropoulos/security
build: migrate package management to pnpm and harden installs
2 parents 5e0e214 + 14d21aa commit 119aaea

9 files changed

Lines changed: 6583 additions & 12402 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ jobs:
2828
timeout 20 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8108/health)" != "200" ]]; do sleep 1; done' || false
2929
3030
- uses: actions/checkout@v4
31-
- uses: actions/setup-node@v3
31+
- uses: pnpm/action-setup@v4
32+
- uses: actions/setup-node@v4
3233
with:
33-
node-version: 22
34-
cache: npm
35-
- run: npm ci
36-
- run: npm run build
37-
- run: npm run ci-lint
38-
- run: npm run typecheck
39-
- run: npm run test
34+
node-version-file: '.nvmrc'
35+
- run: pnpm install --frozen-lockfile
36+
- run: pnpm build
37+
- run: pnpm ci-lint
38+
- run: pnpm typecheck
39+
- run: pnpm test
4040
- uses: actions/upload-artifact@v4
4141
with:
4242
name: coverage

‎.nvmrc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22
1+
24

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Here are some examples with inline comments that walk you through how to use the
8888
To run the examples, from the repo root:
8989

9090
```bash
91-
npm run typesenseServer
91+
pnpm typesenseServer
9292
node doc/examples/server/bulkImport.js
9393
```
9494

@@ -129,7 +129,7 @@ This table refers to server=>client compatibility. Newer versions of the client
129129

130130
## Development
131131

132-
After checking out the repo, run `npm install` to install dependencies. Then run `npm run test:local` to run the linter and tests.
132+
After checking out the repo, run `pnpm install` to install dependencies. Then run `pnpm test:local` to run the linter and tests.
133133

134134
To release a new version, we use the [np](https://github.com/sindresorhus/np) package:
135135

‎flake.lock‎

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎flake.nix‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
description = "Typesense JS dev shell with Node version from .nvmrc";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs =
10+
{ nixpkgs, flake-utils, ... }:
11+
flake-utils.lib.eachDefaultSystem (
12+
system:
13+
let
14+
pkgs = import nixpkgs { inherit system; };
15+
lib = pkgs.lib;
16+
nvmrcRaw = builtins.readFile ./.nvmrc;
17+
nvmrcVersion = lib.strings.removeSuffix "\n" nvmrcRaw;
18+
versionMatch = builtins.match "v?([0-9]+)(\\..*)?" nvmrcVersion;
19+
nodeMajor =
20+
if versionMatch == null then
21+
throw "Unsupported .nvmrc value: ${nvmrcVersion}. Expected a major version like 22 or v22."
22+
else
23+
builtins.elemAt versionMatch 0;
24+
nodePackage = lib.attrByPath [ "nodejs_${nodeMajor}" ] pkgs.nodejs pkgs;
25+
in
26+
{
27+
devShells.default = pkgs.mkShell {
28+
packages = [
29+
nodePackage
30+
pkgs.pnpm
31+
];
32+
33+
shellHook = ''
34+
echo "Using Node $(node -v) from .nvmrc (${nvmrcVersion})"
35+
echo "Using pnpm $(pnpm -v)"
36+
'';
37+
};
38+
}
39+
);
40+
}

0 commit comments

Comments
 (0)