Skip to content

Commit

Permalink
Merge pull request #2 from onebeyond/chore/release-2.0
Browse files Browse the repository at this point in the history
Chore: Release 2.0
  • Loading branch information
UlisesGascon committed Jan 31, 2023
2 parents 36c1e74 + e20fc13 commit 2521118
Show file tree
Hide file tree
Showing 12 changed files with 5,404 additions and 665 deletions.
43 changes: 0 additions & 43 deletions .eslintrc

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Node.js Publish

on:
release:
types: [ created ]

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- name: Publish
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --ignore-scripts --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x, 19.x]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run lint
- run: npm run test
25 changes: 25 additions & 0 deletions .github/workflows/codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Code Climate Test Reporter

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
code-climate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- run: npm ci
- run: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- run: chmod +x ./cc-test-reporter
- run: ./cc-test-reporter before-build
- run: npm run test:coverage
- run: ./cc-test-reporter format-coverage -t lcov coverage/lcov.info
- run: ./cc-test-reporter upload-coverage
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
124 changes: 119 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,63 @@
# Created by https://www.toptal.com/developers/gitignore/api/node,windows,macos,linux
# Edit at https://www.toptal.com/developers/gitignore?templates=node,windows,macos,linux

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

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

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
Expand Down Expand Up @@ -41,8 +94,8 @@ build/Release
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo
Expand All @@ -53,6 +106,9 @@ typings/
# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
Expand All @@ -68,29 +124,40 @@ typings/
# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
# dotenv environment variable files
.env
.env.test
.env.development.local
.env.test.local
.env.production.local
.env.local

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

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# 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

# vuepress v2.x temp and cache directory
.temp

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

Expand All @@ -102,3 +169,50 @@ dist

# 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.*

### Node Patch ###
# Serverless Webpack directories
.webpack/

# Optional stylelint cache

# SvelteKit build / generate output
.svelte-kit

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/node,windows,macos,linux
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.0.0
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</p>


## Usage
## ☕️ Usage
```js
const System = require('systemic')
const knex = require('systemic-knex')
Expand Down Expand Up @@ -44,7 +44,13 @@ new System()
})
```

### Parameters
### 🚩 Compatibility versions

| Version | Node.js | Knex |
|----------|:-------------:|------:|
| 1.0.0 | 10.x-14.x | 0.21.17 |
| 2.0.0 | 14.x-19.x | 0.21.17 |


### 📚 Parameters
Check out [the official documentation](http://knexjs.org/#Installation-client)
8 changes: 8 additions & 0 deletions __mocks__/knex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = jest.fn(({ shouldThrowAnError } = {}) => {
if (shouldThrowAnError) {
throw new Error('Error thrown by the mock')
}
return {
destroy: jest.fn()
}
})
33 changes: 33 additions & 0 deletions __tests__/general.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

const systemicKnext = require('../index')

describe('All Schema files validation', () => {
let knexInstance

beforeAll(() => {
knexInstance = systemicKnext()
})

test('Should expose systemic compatible functions', () => {
expect(knexInstance.start).toBeInstanceOf(Function)
expect(knexInstance.stop).toBeInstanceOf(Function)
})

test('Should expose knex instance with basic config', async () => {
const knexClient = await knexInstance.start({ config: { pool: true } })
expect(knexClient.destroy).toBeTruthy()
})

test('Should expose knex instance with nested knex config)', async () => {
const knexClient = await knexInstance.start({ config: { knex: { pool: true } } })
expect(knexClient.destroy).toBeTruthy()
})

test('Should throw an error if the config is invalid', async () => {
await expect(knexInstance.start({ config: { shouldThrowAnError: true } })).rejects.toThrow()
})

test.todo('Should stop destroying the pool')
test.todo('Should stop without destroying the pool')
test.todo('Should include a pool if the config use a compatible client (mysql, pg..)')
})
Loading

0 comments on commit 2521118

Please sign in to comment.