Skip to content

Commit

Permalink
Prepare 0.2.0-beta1 release (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
slvrtrn authored Jul 19, 2023
1 parent 9da7655 commit e3f89bf
Show file tree
Hide file tree
Showing 57 changed files with 578 additions and 338 deletions.
58 changes: 58 additions & 0 deletions .build/build_and_prepare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { execSync } from 'child_process'
import fs from 'fs'
import * as process from 'process'
;(() => {
const [tag] = process.argv.slice(2)
if (!tag) {
console.error(`Expected a tag as an argument`)
process.exit(1)
}

let packageName = ''
if (tag.endsWith('-browser')) {
packageName = 'client-browser'
} else if (tag.endsWith('-node')) {
packageName = 'client-node'
} else if (tag.endsWith('-common')) {
packageName = 'client-common'
} else {
console.error(`Provided tag ${tag} does not match any packages`)
process.exit(1)
}

fs.copyFileSync(`./packages/${packageName}/package.json`, './package.json')

const packageJson = require('../package.json')
const version = require(`../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 =
require(`../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)

try {
execSync(`./.scripts/build.sh ${packageName}`, { cwd: process.cwd() })
} catch (err) {
console.error(err)
process.exit(1)
}

try {
fs.writeFileSync(
'./package.json',
JSON.stringify(packageJson, null, 2) + '\n',
'utf-8'
)
} catch (err) {
console.error(err)
process.exit(1)
}
process.exit(0)
})()
21 changes: 0 additions & 21 deletions .build/update_version.ts

This file was deleted.

19 changes: 19 additions & 0 deletions .docker/clickhouse/single_node/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,23 @@
<flush_interval_milliseconds>1000</flush_interval_milliseconds>
</query_log>

<http_options_response>
<header>
<name>Access-Control-Allow-Origin</name>
<value>*</value>
</header>
<header>
<name>Access-Control-Allow-Headers</name>
<value>origin, x-requested-with, content-type, authorization</value>
</header>
<header>
<name>Access-Control-Allow-Methods</name>
<value>POST, GET, OPTIONS</value>
</header>
<header>
<name>Access-Control-Max-Age</name>
<value>86400</value>
</header>
</http_options_response>

</clickhouse>
17 changes: 11 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
name: release
on:
workflow_dispatch:
release:
types: [created]
inputs:
version:
type: string
required: true
description: 'Version to release. Released package is based on the version suffix: -browser, -common, -node'
# TODO: trigger on release, currently it's just manual dispatch
# release:
# types: [created]
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -15,9 +21,8 @@ jobs:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: npm i --ignore-scripts
- name: Update package.json version
run: NODE_OPTIONS="-r ts-node/register" node .build/update_version.ts
- run: npm run build
- run: npm publish
- name: Build package and prepare package.json
run: NODE_OPTIONS="-r ts-node/register" node .build/build_and_prepare.ts ${{ github.event.inputs.version }}
- run: npm publish --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ benchmarks/leaks/input
*.tgz
.npmrc
webpack
out
5 changes: 5 additions & 0 deletions .scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
rm -rf out dist
tsc
mkdir -p dist
mv out/$1/src/* dist/
File renamed without changes.
4 changes: 2 additions & 2 deletions karma.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const webpackConfig = require('./webpack.config.js')
const webpackConfig = require('./webpack.dev.js')

module.exports = function (config) {
config.set({
Expand Down Expand Up @@ -57,7 +57,7 @@ module.exports = function (config) {
random: false,
stopOnSpecFailure: false,
stopSpecOnExpectationFailure: true,
timeoutInterval: 5000,
timeoutInterval: 30000,
},
},
})
Expand Down
29 changes: 20 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@
"node": ">=16"
},
"scripts": {
"build": "rm -rf dist; tsc",
"build:all": "rm -rf dist; tsc --project tsconfig.all.json",
"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:browser:package": ".scripts/build.sh client-browser",
"build:browser:minjs": "webpack --config webpack.release.js",
"typecheck": "tsc --project tsconfig.all.json --noEmit",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint --fix . --ext .ts",
"test": "./jasmine.sh jasmine.all.json",
"test:common:unit": "./jasmine.sh jasmine.common.unit.json",
"test:common:integration": "./jasmine.sh jasmine.common.integration.json",
"test:node:unit": "./jasmine.sh jasmine.node.unit.json",
"test:node:tls": "./jasmine.sh jasmine.node.tls.json",
"test:node:integration": "./jasmine.sh jasmine.node.integration.json",
"test": ".scripts/jasmine.sh jasmine.all.json",
"test:common:unit": ".scripts/jasmine.sh jasmine.common.unit.json",
"test:common:integration": ".scripts/jasmine.sh jasmine.common.integration.json",
"test:node:unit": ".scripts/jasmine.sh jasmine.node.unit.json",
"test:node:tls": ".scripts/jasmine.sh jasmine.node.tls.json",
"test:node:integration": ".scripts/jasmine.sh jasmine.node.integration.json",
"test:node:integration:local_cluster": "CLICKHOUSE_TEST_ENVIRONMENT=local_cluster npm run test:node:integration",
"test:node:integration:cloud": "CLICKHOUSE_TEST_ENVIRONMENT=cloud npm run test:node:integration",
"test:browser": "karma start karma.config.cjs",
Expand All @@ -41,6 +44,7 @@
"@types/node": "^18.11.18",
"@types/sinon": "^10.0.15",
"@types/split2": "^3.2.1",
"@types/uuid": "^9.0.2",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"eslint": "^8.32.0",
Expand All @@ -60,17 +64,24 @@
"prettier": "2.8.3",
"sinon": "^15.2.0",
"split2": "^4.1.0",
"terser-webpack-plugin": "^5.3.9",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"tsconfig-paths-webpack-plugin": "^4.0.1",
"typescript": "^4.9.4",
"webpack": "^5.84.1"
"uuid": "^9.0.0",
"webpack": "^5.84.1",
"webpack-cli": "^5.1.4",
"webpack-merge": "^5.9.0"
},
"workspaces": [
"./packages/*"
],
"files": [
"dist"
],
"lint-staged": {
"*.ts": [
"prettier --write",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BaseClickHouseClientConfigOptions } from '@clickhouse/client-common/client'
import type { BaseClickHouseClientConfigOptions } from '@clickhouse/client-common'
import { createClient } from '../../src'

describe('Browser createClient', () => {
Expand Down
20 changes: 15 additions & 5 deletions packages/client-browser/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
{
"name": "@clickhouse/client-browser",
"description": "Official JS client for ClickHouse DB - browser implementation",
"homepage": "https://clickhouse.com",
"version": "0.0.0",
"license": "Apache-2.0",
"keywords": [
"clickhouse",
"sql",
"client"
],
"repository": {
"type": "git",
"url": "https://github.com/ClickHouse/clickhouse-js.git"
},
"private": false,
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"dependencies": {
"@clickhouse/client-common": "*",
"uuid": "^9.0.0"
},
"devDependencies": {
"@types/uuid": "^9.0.2"
"@clickhouse/client-common": "*"
}
}
26 changes: 14 additions & 12 deletions packages/client-browser/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
import type {
BaseClickHouseClientConfigOptions,
InsertParams,
} from '@clickhouse/client-common/client'
import { ClickHouseClient } from '@clickhouse/client-common/client'
import { BrowserConnection } from './connection'
import { BrowserValuesEncoder } from './utils'
import { ResultSet } from './result_set'
import type {
ConnectionParams,
InsertResult,
} from '@clickhouse/client-common/connection'
import type {
DataFormat,
InputJSON,
InputJSONObjectEachRow,
InsertParams,
InsertResult,
BaseResultSet,
QueryParams,
Row,
} from '@clickhouse/client-common'
import { ClickHouseClient } from '@clickhouse/client-common'
import { BrowserConnection } from './connection'
import { ResultSet } from './result_set'
import { BrowserValuesEncoder } from './utils'

export type BrowserClickHouseClient = Omit<
ClickHouseClient<ReadableStream>,
'insert'
'insert' | 'query'
> & {
insert<T>( // patch insert to restrict ReadableStream as a possible insert value
// restrict ReadableStream as a possible insert value
insert<T>(
params: Omit<InsertParams<ReadableStream, T>, 'values'> & {
values: ReadonlyArray<T> | InputJSON<T> | InputJSONObjectEachRow<T>
}
): Promise<InsertResult>
// narrow down the return type here for better type-hinting
query(params: QueryParams): Promise<BaseResultSet<ReadableStream<Row[]>>>
}

export function createClient(
Expand Down
Loading

0 comments on commit e3f89bf

Please sign in to comment.