Skip to content

Commit

Permalink
Initial code (#1)
Browse files Browse the repository at this point in the history
* feat: initial code

* chore: tslint

* refactor: split pg-test out into with-container and pg-test

* feat: mysql-test and beginnings of mysql lib

* chore: specify minimum node version for development

* refactor: pg-migrations has a cleaner API now

This removes most of the warnigns when running tests

* fix: handle port numbers in test containers and wait for mysql to be ready

We now actually test running a basic SQL query and don't treat the database as ready until that succeeds, which can be several seconds.

* feat: mysql query support

* fix: remove old test code from mysql and validate queries

* feat: websql and expo

WebSQL is deprecated and has an awkward API, but Espo's SQLite implementation is still a fully supported interface, and WebSQL has a matching API that can be used for testing in node.js
  • Loading branch information
ForbesLindesay authored Jan 20, 2019
1 parent 14cdbc8 commit 38607eb
Show file tree
Hide file tree
Showing 140 changed files with 15,503 additions and 2 deletions.
99 changes: 99 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
version: 2

refs:
- &container
docker:
- image: node:10
environment:
PG_URL: 'postgres://test-user@localhost:5432/test-db'
MYSQL_URL: 'mysql://test-user:password@localhost:3306/test-db'
- image: circleci/postgres:10.6-alpine-ram
environment:
POSTGRES_USER: test-user
POSTGRES_DB: test-db
- image: circleci/mysql:5.7.24
environment:
MYSQL_USER: test-user
MYSQL_PASSWORD: password
MYSQL_DATABASE: test-db
working_directory: ~/repo
- &restore_cache
restore_cache:
keys:
- v1-dependencies-{{ checksum "yarn.lock" }}
- v1-dependencies-
- &save_cache
save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "yarn.lock" }}
- &npm_auth
run:
name: NPM Auth
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- &bolt_install
run:
name: Bolt Install
command: yarn global add bolt && bolt
- &build
run:
name: Build
command: yarn build:all
- &test
run:
name: Test
command: yarn test

jobs:
all:
<<: *container
steps:
- checkout
- *restore_cache
- *npm_auth
- *bolt_install
- *save_cache
- *build
- *test

master:
<<: *container
steps:
- checkout
- *restore_cache
- *npm_auth
- *bolt_install
- *save_cache
- *build
- *test
- run:
name: Release
command: bolt publish

workflows:
version: 2
all:
jobs:
- all:
context: common-env
filters:
branches:
ignore:
- master
master:
jobs:
- master:
context: common-env
filters:
branches:
only: master
nightly:
triggers:
- schedule:
cron: '0 1 * * *'
filters:
branches:
only: master
jobs:
- all:
context: common-env
2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Coverage directory used by tools like istanbul
coverage

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

# Dependency directory
node_modules

# Users Environment Variables
.lock-wscript

# build output

packages/*/build
packages/*/lib
packages/*/LICENSE.md
packages/*/tsconfig.build.json
packages/*/tsconfig.json
packages/*/.cache

.DS_Store
.env

.last_build
3 changes: 3 additions & 0 deletions .mysqlrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"connectionStringEnvironmentVariable": "MYSQL_URL"
}
3 changes: 3 additions & 0 deletions .pgrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"connectionStringEnvironmentVariable": "PG_URL"
}
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"bracketSpacing": false,
"singleQuote": true,
"trailingComma": "all"
}
5 changes: 5 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Copyright (c) Forbes Lindesay

@databases is an Open Source project licensed under the terms of
the GPLv3 license. Please see <http://www.gnu.org/licenses/gpl-3.0.html>
for license text.
49 changes: 49 additions & 0 deletions crowdin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
project_identifier_env: CROWDIN_DOCUSAURUS_PROJECT_ID
api_key_env: CROWDIN_DOCUSAURUS_API_KEY
base_path: "./"
preserve_hierarchy: true

files:
-
source: '/docs/*.md'
translation: '/website/translated_docs/%locale%/%original_file_name%'
languages_mapping: &anchor
locale:
'af': 'af'
'ar': 'ar'
'bs-BA': 'bs-BA'
'ca': 'ca'
'cs': 'cs'
'da': 'da'
'de': 'de'
'el': 'el'
'es-ES': 'es-ES'
'fa': 'fa-IR'
'fi': 'fi'
'fr': 'fr'
'he': 'he'
'hu': 'hu'
'id': 'id-ID'
'it': 'it'
'ja': 'ja'
'ko': 'ko'
'mr': 'mr-IN'
'nl': 'nl'
'no': 'no-NO'
'pl': 'pl'
'pt-BR': 'pt-BR'
'pt-PT': 'pt-PT'
'ro': 'ro'
'ru': 'ru'
'sk': 'sk-SK'
'sr': 'sr'
'sv-SE': 'sv-SE'
'tr': 'tr'
'uk': 'uk'
'vi': 'vi'
'zh-CN': 'zh-Hans'
'zh-TW': 'zh-Hant'
-
source: '/website/i18n/en.json'
translation: '/website/i18n/%locale%.json'
languages_mapping: *anchor
87 changes: 87 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"name": "atdatabases",
"private": true,
"bolt": {
"workspaces": [
"packages/*"
]
},
"scripts": {
"postinstall": "node scripts/delete-expo-ts && node scripts/postinstall",
"prebuild": "bolt ws run build",
"prebuild:all": "bolt ws run build",
"build": "node scripts/build-all --only-changed",
"build:all": "node scripts/build-all",
"prerelease": "yarn build:all",
"prettier": "prettier --write \"packages/*/src/**/*.{ts,tsx}\"",
"release": "bolt publish",
"pretest": "yarn build && yarn tslint",
"test": "jest",
"posttest": "bolt ws run test",
"watch:jest": "jest --watch",
"clean": "rimraf packages/*/lib && rimraf packages/*/.last_build && rimraf packages/*/.cache && rimraf packages/*/build && rimraf packages/*/node_modules && rimraf node_modules",
"tslint": "tslint './packages/*/src/**/*.{js,jsx,ts,tsx}' -t verbose -p ."
},
"jest": {
"globals": {
"mysql": {
"environmentVariable": "MYSQL_CONNECTION"
}
},
"globalSetup": "./scripts/jest/globalSetup.js",
"globalTeardown": "./scripts/jest/globalTeardown.js",
"transformIgnorePatterns": [
"<rootDir>.*(node_modules)(?!.*databases.*).*$"
],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "/__tests__/.+\\.test\\.(tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json"
]
},
"dependencies": {
"@babel/code-frame": "^7.0.0",
"@babel/core": "^7.2.2",
"@moped/babel-preset": "^0.0.8",
"@types/ajv": "^1.0.0",
"@types/cosmiconfig": "^5.0.3",
"@types/cross-spawn": "^6.0.0",
"@types/jest": "^23.3.10",
"@types/mkdirp": "^0.5.2",
"@types/mysql": "^2.15.5",
"@types/node": "^10.12.17",
"@types/rimraf": "^2.0.2",
"ajv": "^6.7.0",
"babel-core": "^6.26.3",
"chalk": "^2.4.1",
"cosmiconfig": "^5.0.7",
"cross-spawn": "^6.0.5",
"detect-port": "^1.3.0",
"expo": "^32.0.1",
"jest": "^23.6.0",
"lsr": "^2.0.0",
"mkdirp": "^0.5.1",
"mysql2": "^1.6.4",
"pg-error-constants": "^1.0.0",
"pg-minify": "^0.5.5",
"pg-promise": "^8.5.4",
"pg-types": "1.13.0",
"prettier": "^1.15.3",
"rimraf": "^2.6.2",
"ts-jest": "^23.10.5",
"tslint": "^5.12.0",
"typescript": "^3.2.2",
"typescript-json-validator": "^1.0.0",
"websql": "^1.0.0",
"yargs": "^12.0.5"
},
"engines": {
"node": "^10.12.0"
}
}
24 changes: 24 additions & 0 deletions packages/expo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@databases/expo",
"version": "0.0.0",
"description": "",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"dependencies": {
"@databases/websql-core": "^0.0.0"
},
"peerDependencies": {
"expo": "*"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"expo": "^32.0.1"
},
"scripts": {},
"repository": "https://github.com/ForbesLindesay/atdatabases/tree/master/packages/expo",
"bugs": "https://github.com/ForbesLindesay/atdatabases/issues",
"license": "GPL-3.0",
"publishConfig": {
"access": "public"
}
}
21 changes: 21 additions & 0 deletions packages/expo/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {websql, Database, sql} from '@databases/websql-core';

const openDatabase: websql.OpenDatabase = require('expo').SQLite.openDatabase;

export {sql};

export default function connect(name: string) {
return new Database(
new Promise(resolve => {
openDatabase(
name,
undefined as any,
undefined as any,
undefined as any,
database => {
resolve(database);
},
);
}),
);
}
26 changes: 26 additions & 0 deletions packages/mysql-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@databases/mysql-config",
"version": "0.0.0",
"description": "",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"dependencies": {
"@types/ajv": "^1.0.0",
"@types/cosmiconfig": "^5.0.3",
"ajv": "^6.7.0",
"cosmiconfig": "^5.0.7"
},
"devDependencies": {
"typescript-json-validator": "^1.0.0"
},
"scripts": {
"schema": "typescript-json-validator src/MySqlConfig.ts MySqlConfig",
"build": "yarn schema"
},
"repository": "https://github.com/ForbesLindesay/atdatabases/tree/master/packages/mysql-config",
"bugs": "https://github.com/ForbesLindesay/atdatabases/issues",
"license": "GPL-3.0",
"publishConfig": {
"access": "public"
}
}
Loading

0 comments on commit 38607eb

Please sign in to comment.