diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index f1bab091c2..d836e63fa6 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -91,3 +91,25 @@ jobs: --file "scripts/docker-compose.yml" \ down if: matrix.database-type != 'sqlite3' && matrix.database-type != 'better-sqlite3' + + user_experience: + runs-on: ${{ matrix.os }} + name: Test user experience + strategy: + matrix: + node-version: [18.x, 16.x, 14.x, 12.x] + os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + with: { fetch-depth: 1 } + + - name: Setup Node ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + always-auth: false + node-version: ${{ matrix.node-version }} + + - run: npm install + - run: npm pack + - run: npm install -g diff --git a/.gitignore b/.gitignore index b0d47e0f80..4cc39126f1 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ node_modules test.sqlite3 npm-debug.log tmp +knex-*.tgz # Testing for the knex cli: bin/migrations-folder diff --git a/.husky/post-checkout b/.husky/post-checkout new file mode 100755 index 0000000000..9b3d2e813e --- /dev/null +++ b/.husky/post-checkout @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npm run clean && npm run build diff --git a/.husky/pre-commit b/.husky/pre-commit index 36af219892..d24fdfc601 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" npx lint-staged diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c146567fd..634539df1a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -171,11 +171,11 @@ psql -h localhost -U postgres -d knex_test ## Typescript source files -> TL;DR: Starting with release 2.0.0 Knex is adding support for Typescript source files. Thus to develop in this repo you will need to run `npm run build` each time you edit `.ts` files to generate the resulting `.js` files. This is automatically run whenever you run `npm install` so when developing in Javascript you don't have to worry about it. It is encouraged that new functionality and sources be written in Typescript but this is not required. +> TL;DR: Starting with release 2.0.0 Knex is adding support for Typescript source files. Thus to develop in this repo you will need to run `npm run build` each time you edit `.ts` files to generate the resulting `.js` files. This is automatically run whenever you run `npm install` or checkout a new Git branch so when developing in Javascript you don't have to worry about it. It is encouraged that new functionality and sources be written in Typescript but this is not required. Starting with release 2.0.0, Knex is support source additions in Typescript! This allows for better safety in the code added. However, pre-2.0.0 Knex was always written in pure Javascript and thus a "hybrid" approach is being used for 2.0.0 to allow for the new `.ts` files to exist along `.js` files that make up the majority of this repository. -To develop in this repository use the `npm run build` and `npm run clean` commands to compile and delete the `.js` and related files from `.ts` files. If you wish to have the `tsc` compiled watch and recompile on changes then run `npm run build:ts -- --watch`. Note that for easy integration with Javascript the outputted files are done in a "side-by-side" manner meaning that `lib/foo/bar.ts` will result in `lib/foo/bar.js`. This is done automatically via the npm `postinstall` script trigger which executes when you run commands like `npm install` or `npm ci`, thus making it easier to not have to worry about this if you're working in pure Javascript. +To develop in this repository use the `npm run build` and `npm run clean` commands to compile and delete the `.js` and related files from `.ts` files. If you wish to have the `tsc` compiled watch and recompile on changes then run `npm run build:ts -- --watch`. Note that for easy integration with Javascript the outputted files are done in a "side-by-side" manner meaning that `lib/foo/bar.ts` will result in `lib/foo/bar.js`. This is done automatically via the npm script command `"prepare"` whenever you run `npm install` and Git hook for `post-checkout` (added by Husky) which executes when you run commands like `git checkout` , thus making it easier to not have to worry about this if you're working in pure Javascript. The script file `./scripts/update_gitignore_for_tsc_output.js` file is called as part of the `npm run build` command which will update the `lib/.gitignore` file which is used to ensure generated `.js` and related files from `tsc` compilation are not checked into the git repo. diff --git a/package.json b/package.json index 1189e3333d..45bcc94017 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "build": "npm run build:gitignore && npm run build:ts", "clean": "git clean -f -X lib/", "build:ts": "tsc", - "build:gitignore": "./scripts/update_gitignore_for_tsc_output.js run", + "build:gitignore": "node scripts/update_gitignore_for_tsc_output.js run", "format": "prettier --write \"{lib,bin,scripts,test}/**/*.js\"", "debug:test": "mocha --inspect-brk --exit -t 0 test/all-tests-suite.js", "debug:tape": "node --inspect-brk test/tape/index.js", @@ -56,9 +56,7 @@ "stress:init": "docker-compose -f scripts/stress-test/docker-compose.yml up --no-start && docker-compose -f scripts/stress-test/docker-compose.yml start", "stress:test": "node scripts/stress-test/knex-stress-test.js | grep -A 5 -B 60 -- '- STATS '", "stress:destroy": "docker-compose -f scripts/stress-test/docker-compose.yml stop", - "prepare": "husky install", - "prepublishOnly": "npm run clean && npm run build", - "postinstall": "npm run clean && npm run build" + "prepare": "husky install && npm run clean && npm run build" }, "dependencies": { "colorette": "2.0.16", @@ -120,7 +118,7 @@ "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-mocha-no-only": "^1.1.1", - "husky": "^7.0.4", + "husky": "^8.0.1", "jake": "^10.8.5", "JSONStream": "^1.3.5", "lint-staged": "^12.3.7", @@ -221,7 +219,8 @@ }, "files": [ "bin/*", - "lib/*", + "lib/", + "lib/**/*.js", "!lib/**/*.ts", "!lib/**/*.d.ts", "!lib/**/*.js.map",