Skip to content

Commit

Permalink
Convert into monorepo
Browse files Browse the repository at this point in the history
* Using lerna for managing packages
* Add incremental and composite options in tsconfig to improve build optimization and project referencing
* Isolate tests into a separate package and include samples
* Add contribution instructions
* Update Jest config to map module names to db-client's dist and generated folders
  • Loading branch information
w1am committed Apr 22, 2024
1 parent 03f3afa commit 209766e
Show file tree
Hide file tree
Showing 262 changed files with 5,121 additions and 1,668 deletions.
48 changes: 23 additions & 25 deletions .github/workflows/build_and_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,27 @@ jobs:
run: yarn
- name: Build
run: yarn build
- name: Create package
id: package
- name: Create and Test All Packages
run: |
echo "package=$(echo $PWD)$(echo "/")$(npm pack)" >> $GITHUB_OUTPUT
echo "file=$(echo $PWD)$(echo "/.github/files/package_check.txt")" >> $GITHUB_OUTPUT
- name: Create test project
run: |
cd ../
mkdir ./temp
cd ./temp
yarn init -y
yarn add ${{ steps.package.outputs.package }}
yarn add --dev typescript
cp ${{ steps.package.outputs.file }} ./main.ts
- name: Test project compiles
working-directory: ../temp
run: yarn tsc main.ts
--alwaysStrict
--noImplicitAny
--noImplicitReturns
--strictNullChecks
--module system
--moduleResolution node
--target es2018
--lib es2020
--types node
for DIR in packages/*; do
if [ -d "$DIR" ]; then
cd $DIR
if [ -f "package.json" ]; then
PACKAGE_NAME=$(node -p "require('./package.json').name")
SHOULD_PUBLISH=$(node -p "require('./package.json').publishConfig && require('./package.json').publishConfig.public ? 'true' : 'false'")
if [[ $PACKAGE_NAME == @eventstore/* ]] && [[ $SHOULD_PUBLISH == 'true' ]]; then
npm pack
PACKAGE_PATH=$(pwd)/$(ls *.tgz)
mkdir -p ../../../temp/$PACKAGE_NAME
cd ../../../temp/$PACKAGE_NAME
yarn init -y
yarn add $PACKAGE_PATH
yarn add --dev typescript
cp ../../..$DIR/.github/files/package_check.txt ./main.ts
yarn tsc main.ts --alwaysStrict --noImplicitAny --noImplicitReturns --strictNullChecks --module system --moduleResolution node --target es2018 --lib es2020 --types node
cd ../../..
fi
fi
cd ..
fi
done
6 changes: 4 additions & 2 deletions .github/workflows/test_ee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches:
- master
schedule:
- cron: "0 * * * 0" # Every day at 3am UTC.
- cron: "0 3 * * *" # Every day at 3am UTC.

jobs:
tests:
Expand All @@ -16,7 +16,7 @@ jobs:
matrix:
group:
- name: plugins
path: ./src/__test__/plugins
path: ./src/plugins
tailscale: true
env:
# Github only passes secrets to the main repo, so we need to skip some things if they are unavailable
Expand Down Expand Up @@ -45,6 +45,8 @@ jobs:
password: ${{ secrets.CLOUDSMITH_CICD_TOKEN }}
- name: Install
run: yarn
- name: Build
run: yarn build
- name: Run Tests
run: yarn test ${{ matrix.group.path }} --ci --run-in-band --forceExit
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches:
- master
schedule:
- cron: "0 * * * 0" # Every day at 3am UTC.
- cron: "0 3 * * *" # Every day at 3am UTC.

jobs:
test:
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@ on:
required: false

jobs:
tests:
build-and-test:
name: "${{ matrix.group.name }}"
strategy:
fail-fast: false
matrix:
group:
- name: samples
path: ./samples
path: ./src/samples
tailscale: true

- name: connection
path: ./src/__test__/connection
path: ./src/connection
tailscale: true

- name: extra
path: ./src/__test__/extra
path: ./src/extra

- name: persistentSubscription
path: ./src/__test__/persistentSubscription
path: ./src/persistentSubscription

- name: projections
path: ./src/__test__/projections
path: ./src/projections

- name: streams
path: ./src/__test__/streams
path: ./src/streams
env:
# Github only passes secrets to the main repo, so we need to skip some things if they are unavailable
SECRETS_AVAILABLE: ${{ secrets.eventstore_cloud_id != null }}
Expand All @@ -58,6 +58,8 @@ jobs:
node-version: "14.x"
- name: Install
run: yarn
- name: Build
run: yarn build
- name: Run Tests
run: yarn test ${{ matrix.group.path }} --ci --run-in-band --forceExit
env:
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,4 @@ dist
.npmrc
package-lock.json

src/__test__/utils/instances

.vscode
106 changes: 106 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Contributing

Development is done on the `master` branch. We attempt to do our best to ensure that the history remains clean and to do so, we generally ask contributors to squash their commits into a set or single logical commit.

## Initial Setup

**Prerequisites:**
- Node.js (version 14 or higher, although version 12.18.3 is also supported)

**Repository Setup:**
1. Clone the repository:
```bash
$ git clone git@github.com:EventStore/EventStore-Client-NodeJS.git
$ cd EventStore-Client-NodeJS
```
2. Install all necessary dependencies:
```bash
yarn install
```
3. Build the project for the first time:
```bash
yarn build
```
In case of build errors, refresh your setup with:
```bash
npx lerna clean -y && yarn install
```

## Development Practices

**Code Compilation:**
- Standard Build:
```bash
yarn run build
```
- Continuous Build on Changes:
```bash
yarn run build:watch
```

**Testing and Linting:**
- Run the complete test suite:
```bash
yarn run test
```
- Perform code style checks:
```bash
yarn run lint
```

### Tests

Tests are written using [Jest] and require [Docker] and [Docker Compose] to be installed. Then run test with:

```shell script
yarn test
```

Tests can be filtered by prepending the test file or folder to the command

```shell script
$ yarn test connection // all connection tests
$ yarn test ReadAll // only the ReadAll tests
```

To get debug information when running tests use the `test:debug` command.

```shell script
$ yarn test:debug // debug all tests
$ yarn test:debug ReadAll // only the ReadAll tests
```

Specific docker images can be specified via the enviroment variable `EVENTSTORE_IMAGE`.

```shell script
$ yarn cross-env EVENTSTORE_IMAGE=77d63f3f0ab3 jest
```

See [Jest] documentation for more options.

### Debugging

This project uses the [debug] module internally to log information about connections, options and GRPC requests.
To see all the internal logs, set the DEBUG environment variable to `esdb:*` when launching your app.
Logs can be further filtered with glob patterns, for example, only connection logs: `esdb:connection`, everything but grpc logs: `esdb:*,-*:grpc`.

You can set a few environment variables that will further change the behavior of the debug logging:

| Name | Purpose |
| ------------------- | ------------------------------------------------- |
| `DEBUG` | Enables/disables specific debugging namespaces. |
| `DEBUG_COLORS` | Whether or not to use colors in the debug output. |
| `DEBUG_DEPTH` | Object inspection depth. |
| `DEBUG_FD` | File descriptor to write debug output to. |
| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. |

**Note:** The environment variables beginning with `DEBUG_` end up being
converted into an Options object that gets used with `%o`/`%O` formatters.
See the Node.js documentation for [`util.inspect()`] for the complete list.

[docker compose]: https://docs.docker.com/compose/
[docker]: https://www.docker.com/
[jest]: https://jestjs.io/
[debug]: https://github.com/visionmedia/debug
[`util.inspect()`]: https://nodejs.org/api/util.html#util_util_inspect_object_options
[eventstore-client-nodejs]: https://github.com/EventStore/EventStore-Client-NodeJS
Loading

0 comments on commit 209766e

Please sign in to comment.