Skip to content

Commit

Permalink
Merge branch 'master' into missing-spit
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn committed Oct 8, 2024
2 parents 141c552 + 92cb640 commit 0d0a700
Show file tree
Hide file tree
Showing 113 changed files with 779 additions and 1,488 deletions.
6 changes: 4 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ ARG USERNAME=node
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list

# Configure apt and install packages
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
&& apt-get -y install --no-install-recommends dialog 2>&1 \
#
# Verify git and needed tools are installed
&& apt-get -y install git iproute2 procps \
Expand All @@ -33,6 +35,7 @@ RUN apt-get update \
&& echo "deb https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get -y install --no-install-recommends yarn tmux locales postgresql \
&& apt-get install libpq-dev g++ make \
#
# Install eslint globally
&& npm install -g eslint \
Expand All @@ -47,7 +50,6 @@ RUN apt-get update \
&& apt-get install -y sudo \
&& echo node ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
#
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
Expand Down
33 changes: 9 additions & 24 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,13 @@
"dockerComposeFile": "docker-compose.yml",
"service": "web",
"workspaceFolder": "/workspace",

// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},

// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],

// Uncomment the line below if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "npm install",

// Uncomment the next line to have VS Code connect as an existing non-root user in the container. See
// https://aka.ms/vscode-remote/containers/non-root for details on adding a non-root user if none exist.
// "remoteUser": "node",

// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"dbaeumer.vscode-eslint"
]
}
"customizations":{
"vscode": {
"extensions": ["dbaeumer.vscode-eslint"],
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
}
}
}
}
13 changes: 9 additions & 4 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

version: '3'
version: '3.9'
services:
web:
# Uncomment the next line to use a non-root user for all processes. You can also
Expand Down Expand Up @@ -32,16 +32,21 @@ services:
# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

links:
depends_on:
- db

links:
- db:db

db:
image: postgres
image: postgres:14-alpine
restart: unless-stopped
ports:
- 5432:5432
command: postgres -c password_encryption=md5
environment:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_INITDB_ARGS: "--auth-local=md5"
POSTGRES_PASSWORD: pass
POSTGRES_USER: user
POSTGRES_DB: data

8 changes: 7 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"plugins": ["prettier"],
"plugins": ["@typescript-eslint", "prettier"],
"parser": "@typescript-eslint/parser",
"extends": ["plugin:prettier/recommended", "prettier"],
"ignorePatterns": ["node_modules", "coverage", "packages/pg-protocol/dist/**/*", "packages/pg-query-stream/dist/**/*"],
Expand All @@ -11,5 +11,11 @@
"node": true,
"es6": true,
"mocha": true
},
"rules": {
"@typescript-eslint/no-unused-vars": ["error", {
"args": "none"
}],
"no-unused-vars": "off"
}
}
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/packages/pg-connection-string @hjr3
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
- run: yarn install --frozen-lockfile
- run: yarn lint
build:
timeout-minutes: 10
timeout-minutes: 15
needs: lint
services:
postgres:
image: postgres:11
image: ghcr.io/railwayapp-templates/postgres-ssl
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
Expand All @@ -44,8 +44,8 @@ jobs:
- '22'
os:
- ubuntu-latest
name: Node.js ${{ matrix.node }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
name: Node.js ${{ matrix.node }}
runs-on: ubuntu-latest
env:
PGUSER: postgres
PGPASSWORD: postgres
Expand All @@ -71,5 +71,4 @@ jobs:
node-version: ${{ matrix.node }}
cache: yarn
- run: yarn install --frozen-lockfile
# TODO(bmc): get ssl tests working in ci
- run: yarn test
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ If your change involves breaking backwards compatibility please please point tha
### Setting up for local development

1. Clone the repo
2. From your workspace root run `yarn` and then `yarn lerna bootstrap`
3. Ensure you have a PostgreSQL instance running with SSL enabled and an empty database for tests
4. Ensure you have the proper environment variables configured for connecting to the instance
5. Run `yarn test` to run all the tests
2. Ensure you have installed libpq-dev in your system.
3. From your workspace root run `yarn` and then `yarn lerna bootstrap`
4. Ensure you have a PostgreSQL instance running with SSL enabled and an empty database for tests
5. Ensure you have the proper environment variables configured for connecting to the instance
6. Run `yarn test` to run all the tests

## Troubleshooting and FAQ

Expand Down
4 changes: 2 additions & 2 deletions packages/pg-connection-string/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pg-connection-string",
"version": "2.6.4",
"version": "2.7.0",
"description": "Functions for dealing with a PostgresSQL connection string",
"main": "./index.js",
"types": "./index.d.ts",
Expand Down Expand Up @@ -30,7 +30,7 @@
"chai": "^4.1.1",
"coveralls": "^3.0.4",
"istanbul": "^0.4.5",
"mocha": "^7.1.2"
"mocha": "^10.5.2"
},
"files": [
"index.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/pg-cursor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pg-cursor",
"version": "2.11.0",
"version": "2.12.0",
"description": "Query cursor extension for node-postgres",
"main": "index.js",
"directories": {
Expand All @@ -17,8 +17,8 @@
"author": "Brian M. Carlson",
"license": "MIT",
"devDependencies": {
"mocha": "^7.1.2",
"pg": "^8.12.0"
"mocha": "^10.5.2",
"pg": "^8.13.0"
},
"peerDependencies": {
"pg": "^8"
Expand Down
4 changes: 2 additions & 2 deletions packages/pg-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pg-native",
"version": "3.1.0",
"version": "3.2.0",
"description": "A slightly nicer interface to Postgres over node-libpq",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -30,7 +30,7 @@
"concat-stream": "^1.4.6",
"generic-pool": "^2.1.1",
"lodash": "^2.4.1",
"mocha": "3.4.2",
"mocha": "10.5.2",
"node-gyp": ">=10.x",
"okay": "^0.3.0",
"semver": "^4.1.0"
Expand Down
13 changes: 1 addition & 12 deletions packages/pg-native/test/many-connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var bytes = require('crypto').pseudoRandomBytes
describe('many connections', function () {
describe('async', function () {
var test = function (count, times) {
it('connecting ' + count + ' clients ' + times, function (done) {
it(`connecting ${count} clients ${times} times`, function (done) {
this.timeout(200000)

var connectClient = function (n, cb) {
Expand Down Expand Up @@ -38,20 +38,9 @@ describe('many connections', function () {
}

test(1, 1)
test(1, 1)
test(1, 1)
test(5, 5)
test(5, 5)
test(5, 5)
test(5, 5)
test(10, 10)
test(10, 10)
test(10, 10)
test(20, 20)
test(20, 20)
test(20, 20)
test(30, 10)
test(30, 10)
test(30, 10)
})
})
6 changes: 3 additions & 3 deletions packages/pg-pool/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pg-pool",
"version": "3.6.2",
"version": "3.7.0",
"description": "Connection pool for node-postgres",
"main": "index.js",
"directories": {
Expand All @@ -27,11 +27,11 @@
},
"homepage": "https://github.com/brianc/node-pg-pool#readme",
"devDependencies": {
"bluebird": "3.4.1",
"bluebird": "3.7.2",
"co": "4.6.0",
"expect.js": "0.3.1",
"lodash": "^4.17.11",
"mocha": "^7.1.2",
"mocha": "^10.5.2",
"pg-cursor": "^1.3.0"
},
"peerDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/pg-protocol/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "pg-protocol",
"version": "1.6.1",
"version": "1.7.0",
"description": "The postgres client/server binary protocol, implemented in TypeScript",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
"devDependencies": {
"@types/chai": "^4.2.7",
"@types/mocha": "^5.2.7",
"@types/mocha": "^10.0.7",
"@types/node": "^12.12.21",
"chai": "^4.2.0",
"chunky": "^0.0.0",
"mocha": "^7.1.2",
"mocha": "^10.5.2",
"ts-node": "^8.5.4",
"typescript": "^4.0.3"
},
Expand Down
3 changes: 0 additions & 3 deletions packages/pg-protocol/src/b.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
// file for microbenchmarking

import { Writer } from './buffer-writer'
import { serialize } from './index'
import { BufferReader } from './buffer-reader'

const LOOPS = 1000
let count = 0
let start = Date.now()
const writer = new Writer()

const reader = new BufferReader()
const buffer = Buffer.from([33, 33, 33, 33, 33, 33, 33, 0])
Expand Down
11 changes: 0 additions & 11 deletions packages/pg-protocol/src/inbound-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ var parseCompleteBuffer = buffers.parseComplete()
var bindCompleteBuffer = buffers.bindComplete()
var portalSuspendedBuffer = buffers.portalSuspended()

var addRow = function (bufferList: BufferList, name: string, offset: number) {
return bufferList
.addCString(name) // field name
.addInt32(offset++) // table id
.addInt16(offset++) // attribute of column number
.addInt32(offset++) // objectId of field's data type
.addInt16(offset++) // datatype size
.addInt32(offset++) // type modifier
.addInt16(0) // format code, 0 => text
}

var row1 = {
name: 'id',
tableID: 1,
Expand Down
2 changes: 1 addition & 1 deletion packages/pg-protocol/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BackendMessage, DatabaseError } from './messages'
import { DatabaseError } from './messages'
import { serialize } from './serializer'
import { Parser, MessageCallback } from './parser'

Expand Down
1 change: 0 additions & 1 deletion packages/pg-protocol/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
NoticeMessage,
} from './messages'
import { BufferReader } from './buffer-reader'
import assert from 'assert'

// every message is prefixed with a single bye
const CODE_LENGTH = 1
Expand Down
10 changes: 5 additions & 5 deletions packages/pg-query-stream/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pg-query-stream",
"version": "4.6.0",
"version": "4.7.0",
"description": "Postgres query result returned as readable stream",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -30,14 +30,14 @@
},
"devDependencies": {
"@types/chai": "^4.2.13",
"@types/mocha": "^8.0.3",
"@types/mocha": "^10.0.7",
"@types/node": "^14.0.0",
"@types/pg": "^7.14.5",
"JSONStream": "~1.3.5",
"concat-stream": "~1.0.1",
"eslint-plugin-promise": "^6.0.1",
"mocha": "^7.1.2",
"pg": "^8.12.0",
"mocha": "^10.5.2",
"pg": "^8.13.0",
"stream-spec": "~0.3.5",
"ts-node": "^8.5.4",
"typescript": "^4.0.3"
Expand All @@ -46,6 +46,6 @@
"pg": "^8"
},
"dependencies": {
"pg-cursor": "^2.11.0"
"pg-cursor": "^2.12.0"
}
}
2 changes: 2 additions & 0 deletions packages/pg-query-stream/test/async-iterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ if (!process.version.startsWith('v8')) {
const pool = new pg.Pool({ max: 1 })
const client = await pool.connect()

/* eslint-disable @typescript-eslint/no-unused-vars */
for await (const _ of client.query(new QueryStream('select TRUE', [], { highWaterMark: 1 }))) break
for await (const _ of client.query(new QueryStream('select TRUE', [], { highWaterMark: 1 }))) break
for await (const _ of client.query(new QueryStream('select TRUE', [], { highWaterMark: 1 }))) break
/* eslint-enable @typescript-eslint/no-unused-vars */

client.release()
await pool.end()
Expand Down
2 changes: 1 addition & 1 deletion packages/pg-query-stream/test/pauses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import helper from './helper'
import concat from 'concat-stream'
import JSONStream from 'JSONStream'
import QueryStream from '../src'
import { Transform, TransformCallback } from 'stream'
import { Transform } from 'stream'

class PauseStream extends Transform {
constructor() {
Expand Down
Loading

0 comments on commit 0d0a700

Please sign in to comment.