diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..1b5ff3cf --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,40 @@ +version: 2 +jobs: + build_10.15.3: + docker: + - image: 'circleci/node:10.15.3' + working_directory: ~/app + steps: + - checkout + - restore_cache: + keys: + - 'v1-dependencies-{{ checksum "package.json" }}' + - v1-dependencies- + - run: npm install + - save_cache: + paths: + - node_modules + key: 'v1-dependencies-{{ checksum "package.json" }}' + - run: npm test + build_latest: + docker: + - image: 'circleci/node:latest' + working_directory: ~/app + steps: + - checkout + - restore_cache: + keys: + - 'v1-dependencies-{{ checksum "package.json" }}' + - v1-dependencies- + - run: npm install + - save_cache: + paths: + - node_modules + key: 'v1-dependencies-{{ checksum "package.json" }}' + - run: npm test +workflows: + version: 2 + workflow: + jobs: + - build_10.15.3 + - build_latest diff --git a/.github/COMMIT_CONVENTION.md b/.github/COMMIT_CONVENTION.md new file mode 100644 index 00000000..33a78e66 --- /dev/null +++ b/.github/COMMIT_CONVENTION.md @@ -0,0 +1,70 @@ +## Git Commit Message Convention + +> This is adapted from [Angular's commit convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular). + +Using conventional commit messages, we can automate the process of generating the CHANGELOG file. All commits messages will automatically be validated against the following regex. + +``` js +/^(revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|ci|chore|types|build)((.+))?: .{1,50}/ +``` + +## Commit Message Format +A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**: + +> The **scope** is optional + +``` +feat(router): add support for prefix + +Prefix makes it easier to append a path to a group of routes +``` + +1. `feat` is type. +2. `router` is scope and is optional +3. `add support for prefix` is the subject +4. The **body** is followed by a blank line. +5. The optional **footer** can be added after the body, followed by a blank line. + +## Types +Only one type can be used at a time and only following types are allowed. + +- feat +- fix +- docs +- style +- refactor +- perf +- test +- workflow +- ci +- chore +- types +- build + +If a type is `feat`, `fix` or `perf`, then the commit will appear in the CHANGELOG.md file. However if there is any BREAKING CHANGE, the commit will always appear in the changelog. + +### Revert +If the commit reverts a previous commit, it should begin with `revert:`, followed by the header of the reverted commit. In the body it should say: `This reverts commit `., where the hash is the SHA of the commit being reverted. + +## Scope +The scope could be anything specifying place of the commit change. For example: `router`, `view`, `querybuilder`, `database`, `model` and so on. + +## Subject +The subject contains succinct description of the change: + +- use the imperative, present tense: "change" not "changed" nor "changes". +- don't capitalize first letter +- no dot (.) at the end + +## Body + +Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes". +The body should include the motivation for the change and contrast this with previous behavior. + +## Footer + +The footer should contain any information about **Breaking Changes** and is also the place to +reference GitHub issues that this commit **Closes**. + +**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this. + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index e7db8c1f..b205d9e2 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -18,7 +18,7 @@ _Put an `x` in the boxes that apply_ _Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._ -- [ ] I have read the [CONTRIBUTING](https://github.com/adonisjs/adonis-lucid/blob/develop/CONTRIBUTING.md) doc +- [ ] I have read the [CONTRIBUTING](https://github.com/adonisjs/adonis-lucid/blob/master/CONTRIBUTING.md) doc - [ ] Lint and unit tests pass locally with my changes - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added necessary documentation (if appropriate) diff --git a/LICENSE.md b/LICENSE.md index 9045cd1b..5160223a 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ # The MIT License -Copyright 2018 Harminder Virk, contributors +Copyright 2019 Harminder virk, contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/appveyor.yml b/appveyor.yml index 861a0130..fc19a757 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ environment: matrix: - nodejs_version: Stable - - nodejs_version: 8.0.0 + - nodejs_version: 10.15.3 init: git config --global core.autocrlf true install: - ps: 'Install-Product node $env:nodejs_version' @@ -9,7 +9,7 @@ install: test_script: - node --version - npm --version - - npm run test:win + - npm run test build: 'off' clone_depth: 1 matrix: diff --git a/config.json b/config.json index d11827ee..a8efef42 100644 --- a/config.json +++ b/config.json @@ -1,12 +1,11 @@ { "core": true, - "ts": false, + "ts": true, "license": "MIT", "services": [ - "travis", "appveyor", - "coveralls" + "circleci" ], "appveyorUsername": "thetutlage", - "minNodeVersion": "8.0.0" + "minNodeVersion": "10.15.3" } diff --git a/japaFile.js b/japaFile.js index eedb034d..46b457cd 100644 --- a/japaFile.js +++ b/japaFile.js @@ -1,4 +1,6 @@ +require('ts-node/register') + const { configure } = require('japa') configure({ - files: ['test/**/*.spec.js'] + files: ['test/**/*.spec.ts'] }) diff --git a/package.json b/package.json index 89723db1..07656ee1 100644 --- a/package.json +++ b/package.json @@ -2,87 +2,82 @@ "name": "@adonisjs/lucid", "version": "6.1.3", "description": "SQL ORM built on top of Active Record pattern", - "main": "index.js", - "files": [ - "commands", - "config", - "lib", - "providers", - "src", - "templates", - "instructions.js", - "instructions.md" - ], "scripts": { "mrm": "mrm --preset=@adonisjs/mrm-preset", "pretest": "npm run lint", - "test:cleanup": "rm -rf test/functional/database && rm -rf test/unit/tmp", - "test:sqlite": "DB=sqlite node japaFile.js", - "test:win": "node japaFile.js", - "test:mysql": "DB=mysql node japaFile.js", - "test": "nyc npm run test:sqlite && npm run test:mysql", - "coverage": "nyc report --reporter=text-lcov | coveralls", - "commit": "git-cz", - "lint": "standard" + "test": "node japaFile.js", + "prepublishOnly": "npm run build", + "lint": "tslint --project tsconfig.json", + "clean": "del build", + "compile": "npm run lint && npm run clean && tsc", + "build": "npm run compile", + "commit": "git-cz" }, "repository": { "type": "git", "url": "git+https://github.com/adonisjs/adonis-lucid.git" }, - "author": "", + "author": "virk,adonisjs", "license": "MIT", "bugs": { "url": "https://github.com/adonisjs/adonis-lucid/issues" }, "homepage": "https://github.com/adonisjs/adonis-lucid#readme", "dependencies": { - "@adonisjs/generic-exceptions": "^2.0.1", - "chance": "^1.0.18", - "debug": "^4.1.1", - "knex": "^0.16.5", - "lodash": "^4.17.11", - "moment": "^2.24.0", - "pluralize": "^7.0.0", - "pretty-hrtime": "^1.0.3", - "require-all": "^3.0.0" + "knex": "^0.19.1", + "ts-essentials": "^3.0.0", + "utility-types": "^3.7.0" }, "devDependencies": { - "@adonisjs/ace": "^5.0.7", - "@adonisjs/fold": "^4.0.9", - "@adonisjs/mrm-preset": "^1.0.16", - "@adonisjs/sink": "^1.0.17", - "commitizen": "^2.10.1", - "coveralls": "^3.0.3", - "cz-conventional-changelog": "^2.1.0", - "fs-extra": "^7.0.1", - "japa": "^2.0.7", - "japa-cli": "^1.0.1", - "mrm": "^1.2.1", - "mysql": "^2.16.0", - "nyc": "^13.3.0", - "pg": "^7.8.2", + "@adonisjs/mrm-preset": "^2.0.3", + "@poppinss/dev-utils": "^1.0.0", + "@types/dotenv": "^6.1.1", + "@types/node": "^12.6.8", + "clone": "^2.1.2", + "commitizen": "^4.0.3", + "cz-conventional-changelog": "^3.0.2", + "del-cli": "^2.0.0", + "doctoc": "^1.4.0", + "dotenv": "^8.0.0", + "husky": "^3.0.2", + "japa": "^2.0.10", + "mrm": "^1.2.2", + "mysql": "^2.17.1", + "pg": "^7.12.0", "pkg-ok": "^2.3.1", - "semver": "^5.5.1", - "sqlite3": "^4.0.6", - "standard": "^12.0.1" + "sqlite3": "^4.0.9", + "ts-node": "^8.3.0", + "tslint": "^5.18.0", + "tslint-eslint-rules": "^5.4.0", + "typescript": "^3.5.3" }, - "config": { - "commitizen": { - "path": "cz-conventional-changelog" - } + "publishConfig": { + "tag": "next", + "access": "public" }, "nyc": { - "include": [ - "src", - "lib" - ], "exclude": [ "test" + ], + "extension": [ + ".ts" ] }, - "standard": { - "globals": [ - "use" - ] + "main": "build/index.js", + "files": [ + "build/src", + "build/index.d.ts", + "build/index.js" + ], + "husky": { + "hooks": { + "pre-commit": "doctoc README.md --title='## Table of contents' && git add README.md", + "commit-msg": "node ./node_modules/@adonisjs/mrm-preset/validateCommit/conventional/validate.js" + } + }, + "config": { + "commitizen": { + "path": "cz-conventional-changelog" + } } } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..ff4e2734 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/@adonisjs/mrm-preset/_tsconfig" +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 00000000..97f6b537 --- /dev/null +++ b/tslint.json @@ -0,0 +1,8 @@ +{ + "extends": [ + "@adonisjs/mrm-preset/_tslint" + ], + "rules": { + "await-promise": true + } +}