diff --git a/.build/build_and_prepare.ts b/.build/build_and_prepare.ts deleted file mode 100644 index 3ceefbd2..00000000 --- a/.build/build_and_prepare.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { execSync } from 'child_process' -import fs, { readFileSync } from 'fs' -import * as process from 'process' - -void (async () => { - const [pkg] = process.argv.slice(2) - if (!pkg) { - console.error(`Expected package name as an argument`) - process.exit(1) - } - - let packageName = '' - if (pkg.endsWith('web')) { - packageName = 'client-web' - } else if (pkg.endsWith('node')) { - packageName = 'client-node' - } else if (pkg.endsWith('common')) { - packageName = 'client-common' - } else { - console.error(`Provided tag ${pkg} does not match any packages`) - process.exit(1) - } - - try { - fs.copyFileSync(`./packages/${packageName}/package.json`, './package.json') - - const packageJson: { - version: string - dependencies: Record - } = JSON.parse(readFileSync('./package.json').toString()) - - const version = ( - await import(`../packages/${packageName}/src/version` + '.ts') - ).default - console.log(`Current ${packageName} package version is: ${version}`) - packageJson.version = version - - if (packageJson.dependencies['@clickhouse/client-common']) { - const commonVersion = ( - await import('../packages/client-common/src/version' + '.ts') - ).default - console.log(`Updating client-common dependency to ${commonVersion}`) - packageJson['dependencies']['@clickhouse/client-common'] = commonVersion - } - - console.log('Updated package json:') - console.log(packageJson) - - console.log(`Building package ${packageName}...`) - execSync(`./.scripts/build.sh ${packageName}`, { cwd: process.cwd() }) - - fs.writeFileSync( - './package.json', - JSON.stringify(packageJson, null, 2) + '\n', - 'utf-8', - ) - } catch (err) { - console.error(err) - process.exit(1) - } - - process.exit(0) -})() diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c74a468..eee4346a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,16 +23,13 @@ jobs: run: | npm install -g typescript - - name: Build Common package + - name: Build packages run: | - npx tsx .build/build_and_prepare.ts common && npm pack + npm --workspaces run build - - name: Build Node.js package + - name: Pack packages run: | - npx tsx .build/build_and_prepare.ts node && npm pack - - name: Build Web package - run: | - npx tsx .build/build_and_prepare.ts web && npm pack + npm --workspaces pack - name: Rename artifacts run: | diff --git a/.gitignore b/.gitignore index 3abad878..5be6cd53 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ out coverage coverage-web .nyc_output +packages/*/README.md +packages/*/LICENSE diff --git a/.scripts/build.sh b/.scripts/build.sh deleted file mode 100755 index 84177d53..00000000 --- a/.scripts/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -rm -rf out dist -tsc -mkdir -p dist -mv out/$1/src/* dist/ diff --git a/.scripts/update_version.sh b/.scripts/update_version.sh new file mode 100755 index 00000000..5b613509 --- /dev/null +++ b/.scripts/update_version.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -euo pipefail + +version=${1:-} +if [ -z "$version" ]; then + echo "Usage: $0 " + exit 1 +fi + +echo "Setting the version to: $version" + +for package in packages/client-node packages/client-web; do + if [ -f "$package/package.json" ]; then + echo "Updating client-common version in $package/package.json" + json=$(cat "$package/package.json") + echo "$json" | jq --arg version "$version" '.dependencies["@clickhouse/client-common"] = $version' > "$package/package.json" + fi +done + +npm --workspaces version "$version" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 70042869..f0a9753e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -214,27 +214,43 @@ See [#177](https://github.com/ClickHouse/clickhouse-js/issues/177), as it should ## Release process -Don't forget to change the package version in `packages/**/src/version.ts` before the release. +Tools required: + +- Node.js >= `20.x` +- NPM >= `11.x` +- jq (https://stedolan.github.io/jq/) + We prefer to keep versions the same across the packages, and release all at once, even if there were no changes in some. -Common package manual release: +Make sure that the working directory is clean: ```bash -npx tsx .build/build_and_prepare.ts common && npm pack && npm publish +git clean -dfX +npm i ``` -Node.js client manual release: +```bash +.scripts/update_version.sh [new_version] +``` + +Then build the packages: ```bash -npx tsx .build/build_and_prepare.ts node && npm pack && npm publish +npm --workspaces run build ``` -Web client manual release: +Now we're ready to publish. ```bash -npx tsx .build/build_and_prepare.ts web && npm pack && npm publish +npm --workspaces pack +npm --workspaces publish ``` -For simplicity, `build_and_prepare.ts` just overrides the root `package.json`, -which allows to use `npm pack` and `npm publish` as usual despite having multiple workspaces. -Don't commit the generated `package.json` after the manual release. +After that you can commit the changes, create a new Git tag and push it to the repository: + +```bash +git add . +git commit -m "chore: bump version to [new_version]" +git tag v[new_version] +git push origin v[new_version] +``` diff --git a/package-lock.json b/package-lock.json index 5807bb5d..1da70338 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "clickhouse-js", - "version": "0.0.0", + "version": "1.15.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "clickhouse-js", - "version": "0.0.0", + "version": "1.15.0", "license": "Apache-2.0", "workspaces": [ "./packages/*" @@ -17,7 +17,7 @@ "@istanbuljs/nyc-config-typescript": "^1.0.2", "@types/jasmine": "^5.1.8", "@types/jsonwebtoken": "^9.0.10", - "@types/node": "^24.2.1", + "@types/node": "24.2.1", "@types/sinon": "^21.0.0", "@types/split2": "^4.2.3", "@types/uuid": "^11.0.0", @@ -43,7 +43,7 @@ "lint-staged": "^16.1.5", "nyc": "^17.1.0", "parquet-wasm": "0.7.1", - "prettier": "3.6.2", + "prettier": "3.7.4", "sinon": "^21.0.0", "source-map-support": "^0.5.21", "split2": "^4.2.0", @@ -1786,13 +1786,13 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "24.10.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.1.tgz", - "integrity": "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==", + "version": "24.2.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.2.1.tgz", + "integrity": "sha512-DRh5K+ka5eJic8CjH7td8QpYEV6Zo10gfRkjHCO3weqZHWDtAaSTFtl4+VMqOJ4N5jcuhZ9/l+yy8rVgw7BQeQ==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": "~7.16.0" + "undici-types": "~7.10.0" } }, "node_modules/@types/sinon": { @@ -8373,22 +8373,6 @@ "node": ">=18" } }, - "node_modules/playwright/node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/pngjs": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-7.0.0.tgz", @@ -8449,9 +8433,9 @@ } }, "node_modules/prettier": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", - "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", + "version": "3.7.4", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.7.4.tgz", + "integrity": "sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==", "dev": true, "license": "MIT", "bin": { @@ -10463,9 +10447,9 @@ } }, "node_modules/undici-types": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", - "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "version": "7.10.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.10.0.tgz", + "integrity": "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==", "dev": true, "license": "MIT" }, @@ -11383,16 +11367,16 @@ }, "packages/client-common": { "name": "@clickhouse/client-common", - "version": "0.0.0", + "version": "1.15.0", "license": "Apache-2.0", "devDependencies": {} }, "packages/client-node": { "name": "@clickhouse/client", - "version": "0.0.0", + "version": "1.15.0", "license": "Apache-2.0", "dependencies": { - "@clickhouse/client-common": "*" + "@clickhouse/client-common": "1.15.0" }, "devDependencies": { "simdjson": "^0.9.2" @@ -11403,10 +11387,10 @@ }, "packages/client-web": { "name": "@clickhouse/client-web", - "version": "0.0.0", + "version": "1.15.0", "license": "Apache-2.0", "dependencies": { - "@clickhouse/client-common": "*" + "@clickhouse/client-common": "1.15.0" } }, "vitest-poc": { diff --git a/package.json b/package.json index 09028067..672caeee 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "clickhouse-js", "description": "Official JS client for ClickHouse DB", "homepage": "https://clickhouse.com", - "version": "0.0.0", + "version": "1.15.0", "license": "Apache-2.0", "keywords": [ "clickhouse", @@ -19,9 +19,6 @@ }, "scripts": { "build:node:all": "rm -rf out; tsc --project tsconfig.all.json", - "build:common:package": ".scripts/build.sh client-common", - "build:node:package": ".scripts/build.sh client-node", - "build:web:package": ".scripts/build.sh client-web", "build:web:minjs": "webpack --config webpack.release.js", "typecheck": "tsc --project tsconfig.all.json --noEmit", "lint": "eslint .", diff --git a/packages/client-common/package.json b/packages/client-common/package.json index 5c80024d..ca6bd8cf 100644 --- a/packages/client-common/package.json +++ b/packages/client-common/package.json @@ -2,7 +2,7 @@ "name": "@clickhouse/client-common", "description": "Official JS client for ClickHouse DB - common types", "homepage": "https://clickhouse.com", - "version": "0.0.0", + "version": "1.15.0", "license": "Apache-2.0", "keywords": [ "clickhouse", @@ -19,6 +19,10 @@ "files": [ "dist" ], + "scripts": { + "prepack": "cp ../../README.md ../../LICENSE .", + "build": "rm -rf dist; tsc" + }, "dependencies": {}, "devDependencies": {} } diff --git a/packages/client-common/src/client.ts b/packages/client-common/src/client.ts index ff0b7e48..b9c47811 100644 --- a/packages/client-common/src/client.ts +++ b/packages/client-common/src/client.ts @@ -9,12 +9,8 @@ import type { MakeResultSet, WithClickHouseSummary, WithResponseHeaders, -} from '@clickhouse/client-common' -import { - type DataFormat, - defaultJSONHandling, - DefaultLogger, -} from '@clickhouse/client-common' +} from './index' +import { type DataFormat, defaultJSONHandling, DefaultLogger } from './index' import type { InsertValues, NonEmptyArray } from './clickhouse_types' import type { ImplementationDetails, ValuesEncoder } from './config' import { getConnectionParams, prepareConfigWithURL } from './config' diff --git a/packages/client-common/tsconfig.json b/packages/client-common/tsconfig.json new file mode 100644 index 00000000..08413718 --- /dev/null +++ b/packages/client-common/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./src/**/*.ts"], + "compilerOptions": { + "outDir": "./dist" + } +} diff --git a/packages/client-node/package.json b/packages/client-node/package.json index 39d85229..20b91ed8 100644 --- a/packages/client-node/package.json +++ b/packages/client-node/package.json @@ -2,7 +2,7 @@ "name": "@clickhouse/client", "description": "Official JS client for ClickHouse DB - Node.js implementation", "homepage": "https://clickhouse.com", - "version": "0.0.0", + "version": "1.15.0", "license": "Apache-2.0", "keywords": [ "clickhouse", @@ -22,8 +22,12 @@ "files": [ "dist" ], + "scripts": { + "prepack": "cp ../../README.md ../../LICENSE .", + "build": "rm -rf dist; tsc" + }, "dependencies": { - "@clickhouse/client-common": "*" + "@clickhouse/client-common": "1.15.0" }, "devDependencies": { "simdjson": "^0.9.2" diff --git a/packages/client-node/tsconfig.json b/packages/client-node/tsconfig.json new file mode 100644 index 00000000..08413718 --- /dev/null +++ b/packages/client-node/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./src/**/*.ts"], + "compilerOptions": { + "outDir": "./dist" + } +} diff --git a/packages/client-web/package.json b/packages/client-web/package.json index ab64403f..470617d2 100644 --- a/packages/client-web/package.json +++ b/packages/client-web/package.json @@ -2,7 +2,7 @@ "name": "@clickhouse/client-web", "description": "Official JS client for ClickHouse DB - Web API implementation", "homepage": "https://clickhouse.com", - "version": "0.0.0", + "version": "1.15.0", "license": "Apache-2.0", "keywords": [ "clickhouse", @@ -19,7 +19,11 @@ "files": [ "dist" ], + "scripts": { + "prepack": "cp ../../README.md ../../LICENSE .", + "build": "rm -rf dist; tsc" + }, "dependencies": { - "@clickhouse/client-common": "*" + "@clickhouse/client-common": "1.15.0" } } diff --git a/packages/client-web/tsconfig.json b/packages/client-web/tsconfig.json new file mode 100644 index 00000000..08413718 --- /dev/null +++ b/packages/client-web/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./src/**/*.ts"], + "compilerOptions": { + "outDir": "./dist" + } +} diff --git a/tsconfig.json b/tsconfig.json index fb7d0de3..742d2e10 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,10 +20,7 @@ "outDir": "out", "lib": ["esnext", "dom"], "types": ["node", "jasmine"], - "baseUrl": "./", - "paths": { - "@clickhouse/client-common": ["packages/client-common/src/index.ts"] - } + "baseUrl": "./" }, "exclude": ["node_modules"], "include": ["./packages/**/src/**/*.ts"]