Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract src/websockets from Polykey to js-ws #5

Merged
merged 149 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
e525dbc
chore: copied over websocket domain from Polykey/websocket
amydevs Aug 17, 2023
8e16eb1
feat: generic WebSocketClient
amydevs Aug 17, 2023
21ae525
feat: WebSocketServer and WebSocketConnection
amydevs Aug 23, 2023
6d9a7b2
feat: tests now use generated certs for TLS
amydevs Aug 23, 2023
867ec6d
feat: streamIds are now bigints + added conversion utility functions …
amydevs Aug 23, 2023
6365700
fix: stream id to/from parser
amydevs Aug 24, 2023
0a76685
fix: toStreamId properly copies buffer
amydevs Aug 24, 2023
43a4498
feat: WebSocketStream WritableStream
amydevs Aug 24, 2023
dcd3c21
lintfix
amydevs Aug 25, 2023
90e1360
feat: WebSocketStream chunking
amydevs Aug 25, 2023
7fea3e6
feat: WebSocketClient connections are now managed by WebSocketConnect…
amydevs Aug 25, 2023
0404cda
fix: WebSocketStream error handling
amydevs Aug 25, 2023
7877c6a
feat: WebSocketConnection is now more generic
amydevs Aug 25, 2023
8a80720
feat: created WebSocketConnectionMap
amydevs Aug 25, 2023
76be5f1
feat: WebSocketClient connection configuration
amydevs Aug 28, 2023
ed4d444
feat: WebSocketStream buffering and tests
amydevs Aug 28, 2023
9108f2c
feat: WebSocketStream error handling
amydevs Aug 30, 2023
0b9bb93
feat: WebSocketConnection stopping with error codes
amydevs Aug 30, 2023
4bb95e3
feat: mocking for WebSocketStream tests
amydevs Aug 30, 2023
22dd260
feat: WebSocketStream bidi closing
amydevs Aug 30, 2023
a0b4f46
feat: added ability to specify codeToReason and reasonToCode from Web…
amydevs Aug 30, 2023
513856e
lintfix
amydevs Aug 30, 2023
24cdfa9
chore: deleted old WebSocketStream
amydevs Aug 30, 2023
a09fde1
fix: https/ws server errors are propagated onto WebSocketServer
amydevs Aug 30, 2023
52d2a06
feat: errors on WebSocket are now bubbled up
amydevs Aug 30, 2023
8a58602
fix: errors on parsing WebSocketStream messages are now bubbled up
amydevs Aug 30, 2023
633f6e5
fix: buffering writableDesiredSize was going into negative
amydevs Aug 30, 2023
9052a47
fix: WebSocketConnectionMap is now using correct `resource-counter` d…
amydevs Aug 31, 2023
d7610aa
feat: added specifying force stop/destroy to connections and streams
amydevs Aug 31, 2023
ac391db
feat: aligned WebSocketClient to use WebSocketConnection
amydevs Aug 31, 2023
c1eed24
fix: writableDesiredSize should be decremented before stream messages…
amydevs Aug 31, 2023
73f7ae6
fix: bubble up WebSocketStreamDestroyEvents on the server
amydevs Aug 31, 2023
a84fa4c
fix: close and error frames will be ignored on closed streams
amydevs Aug 31, 2023
bce0e7d
fix: readable controller properly closes on WebSocketStream
amydevs Sep 1, 2023
59d7e5c
feat: WebSocketStream tests for varying sized writes
amydevs Sep 1, 2023
051b2cd
lintfix
amydevs Sep 1, 2023
a7e41f2
chore: upgraded to node 20
amydevs Sep 1, 2023
e669551
fix: `single write within buffer size` now uses correct buffer size
amydevs Sep 1, 2023
29dbd2d
feat: migrated events to use js-events system
amydevs Sep 1, 2023
f4d399f
feat: simultaneous writing tests for WebSocketStream
amydevs Sep 1, 2023
8b46495
chore: renamed `StreamType` to `StreamMessageType`
amydevs Sep 1, 2023
baf00ca
fix: renamed ErrorWebSocketStream errors
amydevs Sep 1, 2023
44ddbd6
fix: made a VarInt type that SteamId is
amydevs Sep 1, 2023
3740a78
chore: upgraded js-async-init to 1.9.1 for implicit lifecycle events
amydevs Sep 4, 2023
9addf86
lintfix
amydevs Sep 4, 2023
e447669
fix: WebSocketStream lifecycle methods are now all awaited
amydevs Sep 4, 2023
3cc29fb
feat: WebSocketStream lifecycle tests
amydevs Sep 4, 2023
5a9a641
feat: moved parsing/generation of stream/connection messages to separ…
amydevs Sep 4, 2023
d65262a
lintfix
amydevs Sep 4, 2023
1c1eeaa
fix: exported every thing at root on index.ts
amydevs Sep 4, 2023
b6c4b7f
feat: WebSocketStreamQueue
amydevs Sep 6, 2023
8c1ddfc
feat: changed backpressure to work additively rather than by setting …
amydevs Sep 6, 2023
34fbee3
fix: WebSocketStream shutdowns WebSocketStreamQueue
amydevs Sep 6, 2023
188f4ab
fix: changed 'delete's in WebSocketStreamQueue to set to undefined fo…
amydevs Sep 6, 2023
9476888
fix: WebSocketStream WritableStream write is now looped rather than r…
amydevs Sep 6, 2023
8e66969
fix: readable queue is now cleared earlier on closing ReadableStream
amydevs Sep 6, 2023
ba2c3af
chore: WebSocketStreamQueue documentation
amydevs Sep 6, 2023
0b28258
fix: WebSocketStreamQueue dequeue tests to include byteLengths
amydevs Sep 6, 2023
425a58a
chore: execute WebSocketStream test write/read functions more closely
amydevs Sep 6, 2023
c34755f
fix: readableController is automatically closed off of error in signa…
amydevs Sep 6, 2023
e2b4646
feat: error propagation test for WebSocketStream
amydevs Sep 7, 2023
7367eeb
fix: closing ReadableStream should correctly close the opposing Writa…
amydevs Sep 7, 2023
ec2218f
feat: stream cancelling tests
amydevs Sep 7, 2023
8592b0c
lintfix
amydevs Sep 7, 2023
2e7716f
fix: propagate logger on WebSocketClient
amydevs Sep 7, 2023
dfd3784
feat: benchmarks for baseline + streams
amydevs Sep 7, 2023
e63478d
fix: changed to KiB naming for benches
amydevs Sep 7, 2023
6f07141
feat: benchmark for baseline tcp socket
amydevs Sep 7, 2023
f09e7d0
fix: stream benchmarks now no longer create a new stream for each ite…
amydevs Sep 7, 2023
44bb2f2
lintfix
amydevs Sep 7, 2023
830ddb9
feat: connection benchmarks
amydevs Sep 7, 2023
58d8348
feat: streamIds are encoded on stream creation rather than stream send
amydevs Sep 7, 2023
29cbe3f
fix: updated connection benchmark to follow changes to streamIds
amydevs Sep 7, 2023
7100d95
feat: minimized array concats
amydevs Sep 7, 2023
ab66880
chore: benchmarks for parser/generator improvements
amydevs Sep 7, 2023
58a50cc
lintfix
amydevs Sep 8, 2023
45bbbbf
fix: connection benchmarks were silently failing
amydevs Sep 8, 2023
aa1a0ed
feat: unknown errors for WebSocketStream
amydevs Sep 8, 2023
c142667
fix: connection benchmark removed type wrangling
amydevs Sep 8, 2023
3e9efea
fix: fixed recursive stopping on streams when a connection is stopped
amydevs Sep 8, 2023
c5df0b3
feat: WebSocket tests
amydevs Sep 8, 2023
5a9a4c9
fix: removed utils.test.ts
amydevs Sep 8, 2023
ca680a6
fix: properly stop server and connection if they aren't already stopping
amydevs Sep 8, 2023
38f8e9d
fix: WebSocketConnectionMap counter is protected
amydevs Sep 8, 2023
37ddaae
feat: WebSocketStream metadata
amydevs Sep 8, 2023
06b702b
lintfix
amydevs Sep 8, 2023
73a1972
fix: correct metadata for WebSocketClient
amydevs Sep 8, 2023
f59a714
chore: added README.md
amydevs Sep 8, 2023
5958805
chore: added .gitlab-ci.yml
amydevs Sep 8, 2023
6f0285c
fix: streams created by peers must initiate with an Ack message
amydevs Sep 8, 2023
dda1e9e
fix: made StreamErrorCode an object constant rather than an enum
amydevs Sep 11, 2023
05ce328
fix: config changes to make keepalive and connection start timeouts i…
amydevs Sep 11, 2023
98f4f88
fix: made class comment on WebStreamQueue a docblock
amydevs Sep 11, 2023
4b06dd1
fix: more strict constraints on stopping server from https server errors
amydevs Sep 11, 2023
4a161c2
feat: WebSocketConnection errors with stricter typing
amydevs Sep 11, 2023
5a0b58e
feat: reworked WebSocketConnection events
amydevs Sep 13, 2023
7b1d477
fix: WebSocketConnection.stop now correctly emits close event
amydevs Sep 13, 2023
e2d9308
feat: WebSocketConnection close event test
amydevs Sep 13, 2023
9c2e3fc
lintfix
amydevs Sep 13, 2023
709de3f
feat: StreamMap is now managed by WebSocketConnection
amydevs Sep 14, 2023
ce0b921
feat: WebSocketServer and WebSocketClient lifecycle is now managed by…
amydevs Sep 15, 2023
4f5c4a0
lintfix
amydevs Sep 15, 2023
c378621
feat: WebSocketStream lifecycle is now managed by events
amydevs Sep 15, 2023
1cb4a71
feat: WebSocketStream is now StartStop
amydevs Sep 15, 2023
63e404d
fix: added back WebSocketStream WritablePull
amydevs Sep 15, 2023
53a24dc
chore: benchmarks after js-events integration
amydevs Sep 15, 2023
5ffcf4d
fix: WebSocketStream single write within buffer test
amydevs Sep 15, 2023
37083bb
fix: WebSocketStream error tests
amydevs Sep 15, 2023
3f114c2
feat: use of Buffer.allocUnsafe wherever possible
amydevs Sep 18, 2023
da460da
chore: update benchmarks for buffer.allocUnsafe changes
amydevs Sep 18, 2023
f88efae
fix: WebSocketStream is now using .push for sends instead of .unshift
amydevs Sep 18, 2023
6c5f4b4
fix: promise refactoring for WebSocketStream so that pull/write promi…
amydevs Sep 18, 2023
9e16ca5
fix: naming of tcp baseline benchmarks
amydevs Sep 18, 2023
c36d7e1
feat: verifyPeer on both server and client
amydevs Sep 18, 2023
784ffb1
feat: WebSocketStream StreamMessageType is now represented by 16 bits
amydevs Sep 18, 2023
ef12a13
fix: tests with unneeded writablestreams closed
amydevs Sep 18, 2023
f1a8a6c
fix: updated bench tls config
amydevs Sep 18, 2023
7e6e066
feat: server tests
amydevs Sep 18, 2023
102c8fa
feat: TLS client/server verification tests
amydevs Sep 18, 2023
ce78131
feat: stream closing tests
amydevs Sep 18, 2023
a4762bb
lintfix
amydevs Sep 18, 2023
831e04a
chore: bump js-errors and js-events
amydevs Sep 20, 2023
6f2c47e
fix: removed refernces to unidirectional streams in WebSocketConnection
amydevs Sep 20, 2023
0433875
fix: streamIds now increases as a lesser rate due to bidi only
amydevs Sep 20, 2023
64ce6d5
fix: WebSocketConnection error handling
amydevs Sep 20, 2023
9543af1
lintfix
amydevs Sep 20, 2023
27626e8
feature: added ability to inject https server
amydevs Sep 20, 2023
3ec1632
fix: WebSocketConnection start error handling
amydevs Sep 20, 2023
24d445e
feat: WebSocketConnection Error -> Close Event Flow
amydevs Sep 21, 2023
a4481e6
feat: WebSocketClient now redispatches Connection errors as Client er…
amydevs Sep 21, 2023
ca53ae4
feat: WebSocketStream Error -> Close Event Flow
amydevs Sep 21, 2023
410304a
lintfix
amydevs Sep 21, 2023
60af7de
chore: update inline documentation
amydevs Sep 21, 2023
ea664d9
fix: connectTimeoutTime is now injected through ctx of client
amydevs Sep 21, 2023
7b343d4
feat: WebSocketClient tests
amydevs Sep 21, 2023
acdc8a6
chore: bump js-async-init to 1.10.0
amydevs Sep 22, 2023
f918999
fix: custom verifyCallback is now supplied arrays of DERs instead
amydevs Sep 22, 2023
3d71693
feat: custom verifyCallback TLS Verification tests
amydevs Sep 22, 2023
8c2992b
feat: added path to start options
amydevs Sep 22, 2023
9a6bb58
lintfix
amydevs Sep 22, 2023
d7c834e
feat: ErrorWebSocketConnectionTLS
amydevs Sep 23, 2023
7920417
lintfix
amydevs Sep 23, 2023
2e4bca3
chore: added better inline documentation
amydevs Sep 23, 2023
9489160
feat: hostnames are now resolved for server and client
amydevs Sep 23, 2023
34d3ed8
fix: moved related tests from WebSocket.test.ts to WebSocketServer.te…
amydevs Sep 25, 2023
18e3844
lintfix
amydevs Sep 25, 2023
94bfef8
fix: WebSocketConnection timeout executes properly now
amydevs Sep 25, 2023
d7006d9
chore: WebSocketConnection keepalive tests
amydevs Sep 25, 2023
518e744
fix: typing for WebSocketServer so that a provided `opts.server` will…
amydevs Sep 25, 2023
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
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"message": "Use `globalThis` instead"
}
],
"prefer-rest-params": 0,
"require-yield": 0,
"eqeqeq": ["error", "smart"],
"spaced-comment": [
Expand Down
307 changes: 307 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,307 @@
workflow:
rules:
# Disable merge request pipelines
- if: $CI_MERGE_REQUEST_ID
when: never
- when: always

variables:
GIT_SUBMODULE_STRATEGY: recursive
GH_PROJECT_PATH: "MatrixAI/${CI_PROJECT_NAME}"
GH_PROJECT_URL: "https://${GITHUB_TOKEN}@github.com/${GH_PROJECT_PATH}.git"
# Cache .npm
npm_config_cache: "${CI_PROJECT_DIR}/tmp/npm"
# Prefer offline node module installation
npm_config_prefer_offline: "true"
# Homebrew cache only used by macos runner
HOMEBREW_CACHE: "${CI_PROJECT_DIR}/tmp/Homebrew"

default:
interruptible: true
before_script:
# Replace this in windows runners that use powershell
# with `mkdir -Force "$CI_PROJECT_DIR/tmp"`
- mkdir -p "$CI_PROJECT_DIR/tmp"

# Cached directories shared between jobs & pipelines per-branch per-runner
cache:
key: $CI_COMMIT_REF_SLUG
# Preserve cache even if job fails
when: 'always'
paths:
- ./tmp/npm/
# Homebrew cache is only used by the macos runner
- ./tmp/Homebrew
# Chocolatey cache is only used by the windows runner
- ./tmp/chocolatey/
# `jest` cache is configured in jest.config.js
- ./tmp/jest/

stages:
- check # Linting, unit tests
- build # Cross-platform library compilation, unit tests
- integration # Cross-platform application bundling, integration tests, and pre-release
- release # Cross-platform distribution and deployment

image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner

check:lint:
stage: check
needs: []
script:
- >
nix-shell --arg ci true --run $'
npm run lint;
npm run lint-shell;
'
rules:
# Runs on feature and staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH =~ /^(?:feature.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Manually run on commits other than master and ignore version commits
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
when: manual

check:test:
stage: check
needs: []
script:
- >
nix-shell --arg ci true --run $'
npm test -- --ci --coverage;
'
artifacts:
when: always
reports:
junit:
- ./tmp/junit/junit.xml
coverage_report:
coverage_format: cobertura
path: ./tmp/coverage/cobertura-coverage.xml
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
rules:
# Runs on feature commits and ignores version commits
- if: $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Manually run on commits other than master and staging and ignore version commits
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
when: manual

build:merge:
stage: build
needs: []
allow_failure: true
script:
# Required for `gh pr create`
- git remote add upstream "$GH_PROJECT_URL"
- >
nix-shell --arg ci true --run $'
gh pr create \
--head staging \
--base master \
--title "ci: merge staging to master" \
--body "This is an automatic PR generated by the pipeline CI/CD. This will be automatically fast-forward merged if successful." \
--assignee "@me" \
--no-maintainer-edit \
--repo "$GH_PROJECT_PATH" || true;
printf "Pipeline Attempt on ${CI_PIPELINE_ID} for ${CI_COMMIT_SHA}\n\n${CI_PIPELINE_URL}" \
| gh pr comment staging \
--body-file - \
--repo "$GH_PROJECT_PATH";
'
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/

build:dist:
stage: build
needs: []
script:
- >
nix-shell --arg ci true --run $'
npm run build --verbose;
'
artifacts:
when: always
paths:
- ./dist
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/

build:linux:
stage: build
needs: []
script:
- >
nix-shell --arg ci true --run $'
npm test -- --ci --coverage;
npm run bench;
'
artifacts:
when: always
reports:
junit:
- ./tmp/junit/junit.xml
coverage_report:
coverage_format: cobertura
path: ./tmp/coverage/cobertura-coverage.xml
metrics: ./benches/results/metrics.txt
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/

build:windows:
stage: build
needs: []
tags:
- windows
before_script:
- mkdir -Force "$CI_PROJECT_DIR/tmp"
script:
- .\scripts\choco-install.ps1
- refreshenv
- npm install --ignore-scripts
- $env:Path = "$(npm root)\.bin;" + $env:Path
- npm test -- --ci --coverage
- npm run bench
artifacts:
when: always
reports:
junit:
- ./tmp/junit/junit.xml
coverage_report:
coverage_format: cobertura
path: ./tmp/coverage/cobertura-coverage.xml
metrics: ./benches/results/metrics.txt
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/

build:macos:
stage: build
needs: []
tags:
- saas-macos-medium-m1
image: macos-12-xcode-14
script:
- eval "$(brew shellenv)"
- ./scripts/brew-install.sh
- hash -r
- npm install --ignore-scripts
- export PATH="$(npm root)/.bin:$PATH"
- npm test -- --ci --coverage
- npm run bench
artifacts:
when: always
reports:
junit:
- ./tmp/junit/junit.xml
coverage_report:
coverage_format: cobertura
path: ./tmp/coverage/cobertura-coverage.xml
metrics: ./benches/results/metrics.txt
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/

build:prerelease:
stage: build
needs:
- build:dist
- build:linux
- build:windows
- build:macos
# Don't interrupt publishing job
interruptible: false
script:
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
- echo 'Publishing library prerelease'
- >
nix-shell --arg ci true --run $'
npm publish --tag prerelease --access public;
'
after_script:
- rm -f ./.npmrc
rules:
# Only runs on tag pipeline where the tag is a prerelease version
# This requires dependencies to also run on tag pipeline
# However version tag comes with a version commit
# Dependencies must not run on the version commit
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+-.*[0-9]+$/

integration:merge:
stage: integration
needs:
- build:merge
- job: build:linux
optional: true
- job: build:windows
optional: true
- job: build:macos
optional: true
# Requires mutual exclusion
resource_group: integration:merge
allow_failure: true
variables:
# Ensure that CI/CD is fetching all commits
# this is necessary to checkout origin/master
# and to also merge origin/staging
GIT_DEPTH: 0
script:
- >
nix-shell --arg ci true --run $'
printf "Pipeline Succeeded on ${CI_PIPELINE_ID} for ${CI_COMMIT_SHA}\n\n${CI_PIPELINE_URL}" \
| gh pr comment staging \
--body-file - \
--repo "$GH_PROJECT_PATH";
'
- git remote add upstream "$GH_PROJECT_URL"
- git checkout origin/master
# Merge up to the current commit (not the latest commit)
- git merge --ff-only "$CI_COMMIT_SHA"
- git push upstream HEAD:master
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
# Runs on tag pipeline where the tag is a prerelease or release version
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/

release:distribution:
stage: release
needs:
- build:dist
- build:linux
- build:windows
- build:macos
- integration:merge
# Don't interrupt publishing job
interruptible: false
script:
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
- echo 'Publishing library'
- >
nix-shell --arg ci true --run $'
npm publish --access public;
'
after_script:
- rm -f ./.npmrc
rules:
# Only runs on tag pipeline where the tag is a release version
# This requires dependencies to also run on tag pipeline
# However version tag comes with a version commit
# Dependencies must not run on the version commit
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# js-ws

staging:[![pipeline status](https://gitlab.com/MatrixAI/open-source/js-ws/badges/staging/pipeline.svg)](https://gitlab.com/MatrixAI/open-source/js-ws/commits/staging)
master:[![pipeline status](https://gitlab.com/MatrixAI/open-source/js-ws/badges/master/pipeline.svg)](https://gitlab.com/MatrixAI/open-source/js-ws/commits/master)

WebSocket library for TypeScript/JavaScript applications.

This is built on top of the [ws](https://github.com/websockets/ws) library, providing a multiplexed WebStreams API on top of WebSocket.

## Installation

```sh
npm install --save @matrixai/ws
```

## Development

Run `nix-shell`, and once you're inside, you can use:

```sh
# install (or reinstall packages from package.json)
npm install
# build the dist
npm run build
# run the repl (this allows you to import from ./src)
npm run ts-node
# run the tests
npm run test
# lint the source code
npm run lint
# automatically fix the source
npm run lintfix
```

### Benchmarks

View benchmarks here: https://github.com/MatrixAI/js-ws/blob/master/benches/results with https://raw.githack.com/

### Docs Generation

```sh
npm run docs
```

See the docs at: https://matrixai.github.io/js-ws/

### Publishing

Publishing is handled automatically by the staging pipeline.

Prerelease:

```sh
# npm login
npm version prepatch --preid alpha # premajor/preminor/prepatch
git push --follow-tags
```

Release:

```sh
# npm login
npm version patch # major/minor/patch
git push --follow-tags
```

Manually:

```sh
# npm login
npm version patch # major/minor/patch
npm run build
npm publish --access public
git push
git push --tags
```
Loading