Skip to content

Commit

Permalink
Refactor tooling around package build and release (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
G4brym authored Jun 22, 2024
1 parent 854e192 commit fd2affb
Show file tree
Hide file tree
Showing 19 changed files with 4,005 additions and 3,105 deletions.
15 changes: 0 additions & 15 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,9 @@ end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.php]
indent_style = tab
indent_size = 4

[*.py]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[Makefile]
indent_style = tab
indent_size = 4

[*.sln]
indent_style = tab

[*.{md,mdx}]
trim_trailing_whitespace = false
5 changes: 1 addition & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
*.config.js
*.config.ts
*.test.js
*.test.ts
dist
docs/site
23 changes: 7 additions & 16 deletions .github/workflows/test.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
name: Test
name: CI

on:
push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'LICENSE'
- '.editorconfig'
branches:
- main
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'LICENSE'
- '.editorconfig'
- '**'

jobs:
test:
Expand All @@ -23,15 +12,17 @@ jobs:
matrix:
os:
- ubuntu-latest
node: [18.x, 20.x]
node: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install modules
run: npm install
- name: Run build
run: npm run lint && npm run build
- name: Run tests
run: npm run test
24 changes: 11 additions & 13 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
name: Release & Publish

name: Publish
on:
push:
tags:
- 'v*'

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .npmrc file to publish to npm
uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Set RELEASE_VERSION
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Apply new version
run: node config/preparePublish.cjs
node-version: 22.x
cache: 'npm'
- name: Install modules
run: npm install
- name: Build
run: npm run build
- name: Run build
run: npm run lint && npm run build
- name: Run tests
run: npm run test
- name: Publish to npm
run: npm publish --access public
env:
Expand Down
125 changes: 3 additions & 122 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,124 +1,5 @@

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
node_modules
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*


# Ide
.idea/

.idea
docs/site
.DS_Store
src/**/*.js
5 changes: 0 additions & 5 deletions .husky/commit-msg

This file was deleted.

8 changes: 0 additions & 8 deletions .husky/common.sh

This file was deleted.

1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
. "$(dirname "$0")/common.sh"

npm run prettify
npm run test
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist
docs/site
1 change: 0 additions & 1 deletion commitlint.config.cjs

This file was deleted.

9 changes: 0 additions & 9 deletions config/fileTransformer.cjs

This file was deleted.

18 changes: 0 additions & 18 deletions config/preparePublish.cjs

This file was deleted.

11 changes: 4 additions & 7 deletions docs/pages/databases/bring-your-own-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ For example here is the code that implements support for the node-postgres libra

```ts
// filename: src/interfaces.ts
import { DefaultObject } from 'workers-qb'

// other interfaces...

export interface PGResult {
command: string
lastRowId?: string | number
rowCount: number
results?: Array<Record<string, string | boolean | number | null>>
results?: Array<DefaultObject>
}

export interface PGResultOne {
command: string
lastRowId?: string | number
rowCount: number
results?: Record<string, string | boolean | number | null>
results?: DefaultObject
}
```

Expand Down Expand Up @@ -49,11 +50,7 @@ export class PGQB extends QueryBuilder<PGResult, PGResultOne> {
await this.client.end()
}

async execute(params: {
query: String
arguments?: (string | number | boolean | null | Raw)[]
fetchType?: FetchTypes
}): Promise<any> {
async execute(params: { query: String; arguments?: Primitive[]; fetchType?: FetchTypes }): Promise<any> {
const query = params.query.replaceAll('?', '$')

let result
Expand Down
14 changes: 6 additions & 8 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ module.exports = {
roots: ['<rootDir>/tests'],
testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'./config/fileTransformer.cjs',
},
globals: {
'ts-jest': {
tsconfig: 'tsconfig.json',
},
'^.+\\.(ts|tsx)$': [
'ts-jest',
{
tsconfig: 'tsconfig.json',
},
],
},
}
Loading

0 comments on commit fd2affb

Please sign in to comment.