Skip to content

Commit

Permalink
Fix README typos and tweak open-sourcing configs
Browse files Browse the repository at this point in the history
  • Loading branch information
dimikot committed Aug 26, 2024
1 parent 9f6fa35 commit a177086
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 31 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module.exports = (projectRoot, extraRules = {}) => ({
"typescript-enum",
"typescript-sort-keys",
"unused-imports",
"no-only-tests",
],
settings: {
react: {
Expand Down Expand Up @@ -109,6 +110,10 @@ module.exports = (projectRoot, extraRules = {}) => ({
"@typescript-eslint/no-useless-constructor": ["error"],
"@typescript-eslint/prefer-optional-chain": ["error"],
"@typescript-eslint/consistent-type-imports": ["error"],
"@typescript-eslint/require-array-sort-compare": [
"error",
{ ignoreStringArrays: true },
],
eqeqeq: ["error"],
"object-shorthand": ["error", "always"],
"@typescript-eslint/unbound-method": ["error"],
Expand Down Expand Up @@ -430,6 +435,9 @@ module.exports = (projectRoot, extraRules = {}) => ({
],

quotes: ["error", "double", { avoidEscape: true }],

"no-only-tests/no-only-tests": "error",

...extraRules,
},
});
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"options": { "parser": "typescript" }
}
]
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ Each micro-shard can either be "active" or "inactive".
The library exposes low-level API for other higher-level tools as PG functions:

- `sharding_list_active_shards()`: returns the list of "active" shards
- `sharding_ensure_exist()`: allocates a new range micro-shard
- `sharding_ensure_exist()`: allocates a new range of micro-shards
- `sharding_ensure_active()`: activates a range of micro-shards
- `sharding_ensure_inactive()`: deactivates a range of micro-shards
- `sharding_ensure_absent()`: drops a range of micro-shards
- `sharding_do_on_each()`: a helper function to run an SQL query on all shards
- `sharding_debug_fdw_create()`: creates "debug foreign shards schemas" for each host in the list.
- `sharding_debug_fds_drop()`: drops all debug foreign shards schemas previously created.
- `sharding_debug_fdw_create()`: creates "debug foreign shards schemas" for each host in the list
- `sharding_debug_fdw_drop()`: drops all debug foreign shards schemas previously created
- `sharding_debug_views_create()`: creates "debug views" for tables in all
micro-shards which unions SELECTs from the same-named tables in all shards
(not used in production, only for debugging purposes)
Expand Down
1 change: 0 additions & 1 deletion docker-compose.postgres.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.4"
services:
postgres:
image: postgres:16
Expand Down
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ Each micro-shard can either be "active" or "inactive".
The library exposes low-level API for other higher-level tools as PG functions:

- `sharding_list_active_shards()`: returns the list of "active" shards
- `sharding_ensure_exist()`: allocates a new range micro-shard
- `sharding_ensure_exist()`: allocates a new range of micro-shards
- `sharding_ensure_active()`: activates a range of micro-shards
- `sharding_ensure_inactive()`: deactivates a range of micro-shards
- `sharding_ensure_absent()`: drops a range of micro-shards
- `sharding_do_on_each()`: a helper function to run an SQL query on all shards
- `sharding_debug_fdw_create()`: creates "debug foreign shards schemas" for each host in the list.
- `sharding_debug_fds_drop()`: drops all debug foreign shards schemas previously created.
- `sharding_debug_fdw_create()`: creates "debug foreign shards schemas" for each host in the list
- `sharding_debug_fdw_drop()`: drops all debug foreign shards schemas previously created
- `sharding_debug_views_create()`: creates "debug views" for tables in all
micro-shards which unions SELECTs from the same-named tables in all shards
(not used in production, only for debugging purposes)
Expand Down
2 changes: 1 addition & 1 deletion internal/clean.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
set -e

rm -rf dist yarn.lock package-lock.json pnpm-lock.yaml *.log
rm -rf dist yarn.lock package-lock.json pnpm-lock.yaml node_modules ./*.log
13 changes: 9 additions & 4 deletions internal/with-docker-compose-up.postgres.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#!/bin/bash
set -e

docker-compose -f docker-compose.postgres.yml up --quiet-pull -d
docker compose -f docker-compose.postgres.yml up --quiet-pull -d

for i in $(seq 1 20); do
docker-compose -f docker-compose.postgres.yml ps | grep -q healthy && break
for _i in $(seq 1 20); do
docker compose -f docker-compose.postgres.yml ps | grep -q healthy && break
sleep 1
done

export PGHOST=127.0.0.1
export PGDATABASE=postgres
export PGUSER=postgres
export PGPASSWORD=postgres
eval "$1"

# Run "$1" as a bash command (possibly with && in it) and pass $2, $3, ... as
# properly quoted arguments to it.
cmd="$1"
shift
eval "$cmd \"\$@\""
13 changes: 13 additions & 0 deletions jest.config.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use strict";
module.exports = {
roots: ["<rootDir>/src"],
testMatch: ["**/*.test.ts"],
clearMocks: true,
restoreMocks: true,
...(process.env.IN_JEST_PROJECT
? {}
: { forceExit: true, testTimeout: 30000 }),
transform: {
"\\.ts$": "ts-jest",
},
};
13 changes: 1 addition & 12 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
"use strict";
module.exports = {
roots: ["<rootDir>/src"],
testMatch: ["**/*.test.ts"],
clearMocks: true,
restoreMocks: true,
...(process.env.IN_JEST_PROJECT
? {}
: { forceExit: true, testTimeout: 30000, forceExit: true }),
transform: {
"\\.ts$": "ts-jest",
},
};
module.exports = { ...require("./jest.config.base") };
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@clickup/pg-sharding",
"description": "Micro-shards support for PostgreSQL",
"version": "2.10.296",
"version": "2.10.297",
"license": "MIT",
"keywords": [
"postgresql",
Expand All @@ -19,7 +19,7 @@
"build": "tsc",
"dev": "tsc --watch --preserveWatchOutput",
"lint": "bash internal/lint.sh",
"test": "PGPORT=54833 bash internal/with-docker-compose-up.postgres.sh 'jest && for f in sql/__tests__/test_*.sql; do echo == $f; echo; psql -f $f; echo; echo; done'",
"test": "PGPORT=54833 bash internal/with-docker-compose-up.postgres.sh 'jest && for f in sql/__tests__/test_*.sql; do echo == $f; echo; psql -f $f; echo; echo; done;'",
"psql": "PGPORT=54833 bash internal/with-docker-compose-up.postgres.sh psql",
"docs": "bash internal/docs.sh",
"clean": "bash internal/clean.sh",
Expand Down Expand Up @@ -50,6 +50,7 @@
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-lodash": "^7.4.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react": "^7.32.2",
Expand Down
5 changes: 1 addition & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
{
"extends": "./tsconfig.base.json",
"include": ["src/**/*"]
}
{ "extends": "./tsconfig.base.json" }

0 comments on commit a177086

Please sign in to comment.