Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is a configuration file for both docker and Node.js,
# and it is meant to be committed and version controlled.

# The target version of Meilisearch client
TARGET_VERSION="1.37.0"

# The port at which the Meilisearch client will be served
PORT=7700

# Meilisearch client master key
MASTER_KEY="masterKey"
12 changes: 3 additions & 9 deletions .github/workflows/meilisearch-prototype-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ jobs:
integration_tests:
runs-on: ubuntu-latest
needs: ["meilisearch-version"]
services:
meilisearch:
image: getmeili/meilisearch-enterprise:${{ needs.meilisearch-version.outputs.version }}
env:
MEILI_MASTER_KEY: "masterKey"
MEILI_NO_ANALYTICS: "true"
MEILI_EXPERIMENTAL_ALLOWED_IP_NETWORKS: "any"
ports:
- "7700:7700"
strategy:
matrix:
node-version: ["20", "22"]
Expand All @@ -55,5 +46,8 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Set up Meilisearch
run: TARGET_VERSION=${{ needs.meilisearch-version.outputs.version }} docker compose --env-file .conf up -d

- name: Run tests
run: pnpm test
25 changes: 3 additions & 22 deletions .github/workflows/pre-release-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,9 @@ on:
- "pre-release-beta/**"

jobs:
meilisearch-version:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || startsWith(github.base_ref, 'bump-meilisearch-v') || startsWith(github.base_ref, 'pre-release-beta')
outputs:
version: ${{ steps.grep-step.outputs.meilisearch_version }}
steps:
- uses: actions/checkout@v6
- name: Grep docker beta version of Meilisearch
id: grep-step
run: |
MEILISEARCH_VERSION=$(curl https://raw.githubusercontent.com/meilisearch/integration-guides/main/scripts/get-latest-meilisearch-rc.sh | sh)
echo "meilisearch_version=$MEILISEARCH_VERSION" >> $GITHUB_OUTPUT
integration_tests:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || startsWith(github.base_ref, 'bump-meilisearch-v') || startsWith(github.base_ref, 'pre-release-beta')
needs: ["meilisearch-version"]
services:
meilisearch:
image: getmeili/meilisearch-enterprise:${{ needs.meilisearch-version.outputs.version }}
env:
MEILI_MASTER_KEY: "masterKey"
MEILI_NO_ANALYTICS: "true"
MEILI_EXPERIMENTAL_ALLOWED_IP_NETWORKS: "any"
ports:
- "7700:7700"
strategy:
matrix:
node-version: ["20", "22"]
Expand All @@ -52,5 +30,8 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Set up Meilisearch
run: docker compose up -d

Comment thread
flevi29 marked this conversation as resolved.
- name: Run tests
run: pnpm test
15 changes: 4 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ jobs:
!startsWith(github.base_ref, 'prototype-beta/') &&
!startsWith(github.head_ref, 'pre-release-beta/')
runs-on: ubuntu-latest
services:
meilisearch:
image: getmeili/meilisearch-enterprise:latest
env:
MEILI_MASTER_KEY: "masterKey"
MEILI_NO_ANALYTICS: "true"
MEILI_EXPERIMENTAL_ALLOWED_IP_NETWORKS: "any"
ports:
- "7700:7700"
strategy:
fail-fast: false
matrix:
Expand All @@ -45,8 +36,12 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Set up Meilisearch
run: docker compose --env-file .conf up -d

- name: Run tests with coverage
run: pnpm test --coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
env:
Expand All @@ -67,7 +62,5 @@ jobs:
- uses: actions/checkout@v6
- uses: ./.github/actions/set-up-node

- name: Build project
run: pnpm build
- name: Run types check
run: pnpm types
22 changes: 15 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,26 @@ What we expect:

### Requirements

To run this project, you will need:
To run and test this project, you will need:

- [Node.js LTS](https://nodejs.org/en/about/previous-releases)
- [pnpm](https://pnpm.io/installation#using-corepack)
- [Docker](https://www.docker.com/)

### Setup

You can set up your local environment natively or using `docker`, check out the [`docker-compose.yml`](/docker-compose.yml).

Example of running all the checks with docker:
To install dependencies:

```bash
docker-compose run --rm package bash -c "pnpm install && pnpm test && pnpm lint"
pnpm install
```

To install dependencies:
Set up environment variables and Meilisearch client docker service:

```bash
pnpm install
# Start the Meilisearch client docker service
# with the appropriate configuration file
docker compose --env-file .conf up -d
```

### Tests and Linter
Expand Down Expand Up @@ -109,6 +110,13 @@ Some notes on GitHub PRs:
- All PRs must be reviewed and approved by at least one maintainer.
- The PR title should be accurate and descriptive of the changes. The title of the PR will be indeed automatically added to the next [release changelogs](https://github.com/meilisearch/meilisearch-js/releases/).

### Developing features for a newer Meilisearch client target version

Change `TARGET_VERSION` in [`/.conf`](/.conf) to the desired newer Meilisearch version.

> [!IMPORTANT]
> The first PR for such changes should implement all the features that break the tests first.

## Release Process (for the internal team only)

Meilisearch tools follow the [Semantic Versioning Convention](https://semver.org/).
Expand Down
20 changes: 3 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
services:
package:
image: node:22
tty: true
stdin_open: true
working_dir: /home/package
environment:
- MEILISEARCH_URL=http://meilisearch:7700
depends_on:
- meilisearch
links:
- meilisearch
volumes:
- ./:/home/package

meilisearch:
image: getmeili/meilisearch-enterprise:v1.37.0
image: getmeili/meilisearch-enterprise:v${TARGET_VERSION}
ports:
- "7700:7700"
- "${PORT}:7700"
environment:
- MEILI_MASTER_KEY=masterKey
- MEILI_MASTER_KEY=${MASTER_KEY}
- MEILI_NO_ANALYTICS=true
- MEILI_EXPERIMENTAL_ALLOWED_IP_NETWORKS=any
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@
"default": "./dist/cjs/token.cjs"
}
},
"imports": {
"#src/*": "./src/*.ts"
},
"sideEffects": false,
"repository": {
"type": "git",
"url": "https://github.com/meilisearch/meilisearch-js.git"
},
"scripts": {
"playground:javascript": "vite serve playgrounds/javascript --open",
"playground:javascript": "pnpm -F=meilisearch-js-playground dev",
"build:docs": "typedoc",
"build": "vite build && tsc -p tsconfig.build.json && vite --mode production-umd build",
"postbuild": "node scripts/build.js",
Expand Down
8 changes: 1 addition & 7 deletions playgrounds/javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
{
"name": "meilisearch-js-playground",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"devDependencies": {
"vite": "^6.0.11"
"dev": "vite --open"
}
}
4 changes: 2 additions & 2 deletions playgrounds/javascript/src/meilisearch.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Index, Meilisearch } from "../../../src/index.js";

const client = new Meilisearch({
host: "http://127.0.0.1:7700",
apiKey: "masterKey",
host: `http://127.0.0.1:${__PORT__}`,
apiKey: __MASTER_KEY__,
});
const indexUid = "movies";
const index = client.index<{ id: number; title: string; genres: string[] }>(
Expand Down
2 changes: 2 additions & 0 deletions playgrounds/javascript/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/// <reference types="vite/client" />
declare const __MASTER_KEY__: string;
declare const __PORT__: string;
20 changes: 20 additions & 0 deletions playgrounds/javascript/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { env, loadEnvFile } from "node:process";
import { defineConfig } from "vite";

loadEnvFile(new URL("../../.conf", import.meta.url));
const { MASTER_KEY, PORT } = env;
if (MASTER_KEY === undefined || PORT === undefined) {
throw new Error("MASTER_KEY and/or PORT environment variables missing", {
cause: { MASTER_KEY, PORT },
});
}

export default defineConfig({
server: { host: "127.0.0.1" },
define: Object.fromEntries(
Object.entries({ PORT, MASTER_KEY }).map(([key, val]) => [
`__${key}__`,
JSON.stringify(val),
]),
),
});
Loading