├── .eslintignore ├── .eslintrc.js ├── .github └── workflows │ └── nodejs.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── __tests__ └── migrate.spec.ts ├── commitlint.config.js ├── jest.config.js ├── package.json ├── src ├── index.ts └── migrate.ts ├── tsconfig.base.json ├── tsconfig.build.json ├── tsconfig.json └── yarn.lock /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | 4 | # Build 5 | dist 6 | lib 7 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true 3 | , parser: '@typescript-eslint/parser' 4 | , plugins: [ 5 | '@typescript-eslint' 6 | ] 7 | , extends: [ 8 | 'eslint:recommended' 9 | , 'plugin:@typescript-eslint/recommended' 10 | ] 11 | , rules: { 12 | 'no-constant-condition': 'off' 13 | , 'no-async-promise-executor': 'off' 14 | , '@typescript-eslint/no-inferrable-types': 'off' 15 | , '@typescript-eslint/ban-types': 'off' 16 | , '@typescript-eslint/ban-ts-comment': 'off' 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.github/workflows/nodejs.yml: -------------------------------------------------------------------------------- 1 | name: Node.js CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | strategy: 11 | matrix: 12 | node-version: [14.x, 16.x] 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Use Node.js ${{ matrix.node-version }} 17 | uses: actions/setup-node@v1 18 | with: 19 | node-version: ${{ matrix.node-version }} 20 | - run: npm install -g yarn 21 | - run: yarn install 22 | - run: yarn lint 23 | - run: yarn test 24 | env: 25 | CI: true 26 | - run: yarn build 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | 106 | # Build 107 | lib 108 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | ### [0.1.19](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.18...v0.1.19) (2024-09-24) 6 | 7 | ### [0.1.18](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.17...v0.1.18) (2023-12-03) 8 | 9 | ### [0.1.17](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.16...v0.1.17) (2023-06-10) 10 | 11 | 12 | ### Bug Fixes 13 | 14 | * export src ([5015e15](https://github.com/BlackGlory/better-sqlite3-migrations/commit/5015e15615bcdd2803a61e2260de0ac39c85312c)) 15 | 16 | ### [0.1.16](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.15...v0.1.16) (2022-11-23) 17 | 18 | ### [0.1.15](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.14...v0.1.15) (2022-08-11) 19 | 20 | ### [0.1.14](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.13...v0.1.14) (2022-08-11) 21 | 22 | 23 | ### Bug Fixes 24 | 25 | * lazy ([7584299](https://github.com/BlackGlory/better-sqlite3-migrations/commit/75842997ec949197fec239f7efabec820000f440)) 26 | 27 | ### [0.1.13](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.12...v0.1.13) (2022-08-11) 28 | 29 | ### [0.1.12](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.11...v0.1.12) (2022-08-11) 30 | 31 | ### [0.1.11](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.10...v0.1.11) (2022-08-06) 32 | 33 | ### [0.1.10](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.9...v0.1.10) (2022-08-01) 34 | 35 | ### [0.1.9](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.8...v0.1.9) (2022-02-16) 36 | 37 | 38 | ### Features 39 | 40 | * skip migrations when the maximum version of migrations < user_version ([4d48e6c](https://github.com/BlackGlory/better-sqlite3-migrations/commit/4d48e6c51e0c914b60ffdbdeb7e1ce27719baa55)) 41 | 42 | ### [0.1.8](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.7...v0.1.8) (2022-02-16) 43 | 44 | 45 | ### Features 46 | 47 | * ensure migrations are run in transactions ([9d0e6a0](https://github.com/BlackGlory/better-sqlite3-migrations/commit/9d0e6a069d08a2e43357e6d807d963d962303d98)) 48 | 49 | ### [0.1.7](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.6...v0.1.7) (2021-07-03) 50 | 51 | ### [0.1.6](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.5...v0.1.6) (2021-03-17) 52 | 53 | ### [0.1.5](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.4...v0.1.5) (2021-02-25) 54 | 55 | ### [0.1.4](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.3...v0.1.4) (2021-02-20) 56 | 57 | ### [0.1.3](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.2...v0.1.3) (2021-02-20) 58 | 59 | ### [0.1.2](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.1...v0.1.2) (2021-02-03) 60 | 61 | ### [0.1.1](https://github.com/BlackGlory/better-sqlite3-migrations/compare/v0.1.0...v0.1.1) (2020-10-19) 62 | 63 | ## 0.1.0 (2020-10-19) 64 | 65 | 66 | ### Features 67 | 68 | * add migrate ([63b9402](https://github.com/BlackGlory/better-sqlite3-migrations/commit/63b9402dee593bc836697d70210ca3e57264c381)) 69 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 BlackGlory 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # better-sqlite3-migrations 2 | A utility for database migrations with [better-sqlite3]. 3 | 4 | The module using [user_version] to record the schema version. 5 | 6 | [better-sqlite3]: https://www.npmjs.com/package/better-sqlite3 7 | [user_version]: https://www.sqlite.org/pragma.html#pragma_user_version 8 | 9 | ## Install 10 | ```sh 11 | npm install --save @blackglory/better-sqlite3-migrations 12 | # or 13 | yarn add @blackglory/better-sqlite3-migrations 14 | ``` 15 | 16 | ## API 17 | ```ts 18 | interface IMigration { 19 | version: number 20 | up: string | ((db: Database) => void) 21 | down: string | ((db: Database) => void) 22 | } 23 | ``` 24 | 25 | You may need [migration-files]. 26 | 27 | [migration-files]: https://github.com/BlackGlory/migration-files 28 | 29 | ### migrate 30 | ```ts 31 | function migrate(db: Database, migrations: IMigration[], targetVersion?: number): void 32 | ``` 33 | 34 | If targetVersion is `undefined`, then use the maximum version of migrations. 35 | 36 | ## FAQ 37 | ### Can multiple instances migrate in parallel? 38 | Yes, the `user_version` update is visible to every database connection. 39 | When the maximum migration version is less than the `user_version` (which means it is an obsolete instance), it will skip the migration. 40 | 41 | You may need a proper retry strategy, 42 | because each migration uses `BEGIN IMMEDIATE` to ensure that parallel write transactions fail early. 43 | -------------------------------------------------------------------------------- /__tests__/migrate.spec.ts: -------------------------------------------------------------------------------- 1 | import Database = require('better-sqlite3') 2 | import type { Database as IDatabase } from 'better-sqlite3' 3 | import { migrate, IMigration } from '@src/migrate' 4 | 5 | const migrations: IMigration[] = [ 6 | { 7 | version: 1 8 | , up: ` 9 | CREATE TABLE test ( 10 | id INTEGER PRIMARY KEY 11 | ); 12 | ` 13 | , down: ` 14 | DROP TABLE test; 15 | ` 16 | } 17 | , { 18 | version: 2 19 | , up(db) { 20 | db.exec(` 21 | ALTER TABLE test 22 | ADD COLUMN name TEXT; 23 | `) 24 | } 25 | , down(db) { 26 | db.transaction(() => { 27 | db.exec(` 28 | -- https://www.sqlite.org/faq.html#q11 29 | CREATE TEMPORARY TABLE test_backup ( 30 | id INTEGER PRIMARY KEY 31 | , name TEXT 32 | ); 33 | 34 | INSERT INTO test_backup 35 | SELECT id, name 36 | FROM test; 37 | 38 | DROP TABLE test; 39 | 40 | CREATE TABLE test ( 41 | id INTEGER PRIMARY KEY 42 | ); 43 | 44 | INSERT INTO test 45 | SELECT id 46 | FROM test_backup; 47 | 48 | DROP TABLE test_backup; 49 | `) 50 | })() 51 | } 52 | } 53 | ] 54 | 55 | describe('migrate(db: Database, migrations: Migration[], targetVersion: number): void', () => { 56 | describe('The maximum version of migrations < user_version', () => { 57 | it('skip migrations', () => { 58 | const db = new Database(':memory:') 59 | setDatabaseVersion(db, 999) 60 | 61 | migrate(db, migrations, 2) 62 | const versionAfter = getDatabaseVersion(db) 63 | 64 | expect(versionAfter).toBe(999) 65 | }) 66 | }) 67 | 68 | describe('upgrade', () => { 69 | it('upgrade', () => { 70 | const db = new Database(':memory:') 71 | 72 | const versionBefore = getDatabaseVersion(db) 73 | migrate(db, migrations, 2) 74 | const versionAfter = getDatabaseVersion(db) 75 | const tables = getDatabaseTables(db) 76 | const schema = getTableSchema(db, 'test') 77 | 78 | expect(versionBefore).toBe(0) 79 | expect(versionAfter).toBe(2) 80 | expect(tables).toEqual(['test']) 81 | expect(schema).toMatchObject([ 82 | { 83 | name: 'id' 84 | , type: 'INTEGER' 85 | } 86 | , { 87 | name: 'name' 88 | , type: 'TEXT' 89 | } 90 | ]) 91 | }) 92 | }) 93 | 94 | describe('downgrade', () => { 95 | it('downgrade', () => { 96 | const db = new Database(':memory:') 97 | migrate(db, migrations, 2) 98 | 99 | const versionBefore = getDatabaseVersion(db) 100 | migrate(db, migrations, 0) 101 | const versionAfter = getDatabaseVersion(db) 102 | const tables = getDatabaseTables(db) 103 | 104 | expect(versionBefore).toBe(2) 105 | expect(versionAfter).toBe(0) 106 | expect(tables).toEqual([]) 107 | }) 108 | }) 109 | }) 110 | 111 | function setDatabaseVersion(db: IDatabase, version: number): void { 112 | db.exec(`PRAGMA user_version = ${version};`) 113 | } 114 | 115 | function getDatabaseVersion(db: IDatabase): number { 116 | const result = db.prepare('PRAGMA user_version;').get() as { 117 | user_version: number 118 | } 119 | return result['user_version'] 120 | } 121 | 122 | function getTableSchema(db: IDatabase, tableName: string): Array<{ 123 | name: string 124 | type: string 125 | }> { 126 | const result = db.prepare(`PRAGMA table_info(${tableName});`).all() as Array<{ 127 | name: string 128 | type: string 129 | }> 130 | return result 131 | } 132 | 133 | function getDatabaseTables(db: IDatabase): string[] { 134 | const result = db.prepare(` 135 | SELECT name 136 | FROM sqlite_master 137 | WHERE type='table'; 138 | `).all() as Array<{ name: string }> 139 | 140 | return result.map(x => x['name']) 141 | } 142 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'] 3 | } 4 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | const { pathsToModuleNameMapper } = require('ts-jest') 2 | const { compilerOptions } = require('./tsconfig.base.json') 3 | 4 | module.exports = { 5 | preset: 'ts-jest' 6 | , testEnvironment: 'node' 7 | , testMatch: ['**/__tests__/**/?(*.)+(spec|test).[jt]s?(x)'] 8 | , moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { 9 | prefix: '/' 10 | }) 11 | } 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@blackglory/better-sqlite3-migrations", 3 | "version": "0.1.19", 4 | "description": "A utility for database migrations with better-sqlite3", 5 | "keywords": [ 6 | "migration", 7 | "migrations", 8 | "better-sqlite3", 9 | "up", 10 | "down", 11 | "sql" 12 | ], 13 | "files": [ 14 | "lib", 15 | "src" 16 | ], 17 | "main": "lib/es2018/index.js", 18 | "types": "lib/es2018/index.d.ts", 19 | "repository": "git@github.com:BlackGlory/better-sqlite3-migrations.git", 20 | "author": "BlackGlory ", 21 | "license": "MIT", 22 | "sideEffects": false, 23 | "scripts": { 24 | "lint": "eslint --ext .js,.jsx,.ts,.tsx --quiet src __tests__", 25 | "test": "jest --config jest.config.js", 26 | "test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand", 27 | "test:coverage": "jest --coverage --config jest.config.js", 28 | "prepublishOnly": "run-s clean build", 29 | "clean": "rimraf lib", 30 | "build": "run-p build:*", 31 | "build:es2015": "run-s build:es2015:*", 32 | "build:es2015:compile": "tsc --project tsconfig.build.json --target es2015 --outDir lib/es2015", 33 | "build:es2015:patch": "tscpaths -p tsconfig.build.json -s ./src -o ./lib/es2015", 34 | "build:es2018": "run-s build:es2018:*", 35 | "build:es2018:compile": "tsc --project tsconfig.build.json --target es2018 --outDir lib/es2018", 36 | "build:es2018:patch": "tscpaths -p tsconfig.build.json -s ./src -o ./lib/es2018", 37 | "release": "standard-version" 38 | }, 39 | "husky": { 40 | "hooks": { 41 | "pre-commit": "run-s clean lint build test", 42 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" 43 | } 44 | }, 45 | "devDependencies": { 46 | "@commitlint/cli": "^17.3.0", 47 | "@commitlint/config-conventional": "^17.3.0", 48 | "@types/better-sqlite3": "^7.6.8", 49 | "@types/jest": "^27.4.0", 50 | "@types/node": "14", 51 | "@typescript-eslint/eslint-plugin": "^5.44.0", 52 | "@typescript-eslint/parser": "^5.44.0", 53 | "better-sqlite3": "^8.0.0", 54 | "eslint": "^8.28.0", 55 | "husky": "4", 56 | "jest": "^29.3.1", 57 | "npm-run-all": "^4.1.5", 58 | "rimraf": "^3.0.2", 59 | "standard-version": "^9.5.0", 60 | "ts-jest": "^29.0.3", 61 | "tscpaths": "^0.0.9", 62 | "typescript": "^4.9.3" 63 | }, 64 | "dependencies": { 65 | "@blackglory/errors": "^2.3.0", 66 | "@blackglory/types": "^1.4.0", 67 | "extra-lazy": "^1.3.1" 68 | }, 69 | "peerDependencies": { 70 | "better-sqlite3": "^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0" 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './migrate' 2 | -------------------------------------------------------------------------------- /src/migrate.ts: -------------------------------------------------------------------------------- 1 | import type { Database } from 'better-sqlite3' 2 | import { isFunction } from '@blackglory/types' 3 | import { assert } from '@blackglory/errors' 4 | import { withLazyStatic, lazyStatic } from 'extra-lazy' 5 | 6 | export interface IMigration { 7 | version: number 8 | up: string | ((db: Database) => void) 9 | down: string | ((db: Database) => void) 10 | } 11 | 12 | export const migrate: ( 13 | db: Database 14 | , migrations: IMigration[] 15 | , targetVersion?: number | undefined 16 | ) => void 17 | = withLazyStatic(function ( 18 | db: Database 19 | , migrations: IMigration[] 20 | , targetVersion: number = getMaximumVersion(migrations) 21 | ): void { 22 | const maxVersion = getMaximumVersion(migrations) 23 | const migrate = lazyStatic(() => db.transaction(( 24 | targetVersion: number 25 | , maxVersion: number 26 | ) => { 27 | const currentVersion = getDatabaseVersion(db) 28 | if (maxVersion < currentVersion) { 29 | return true 30 | } else { 31 | if (currentVersion === targetVersion) { 32 | return true 33 | } else if (currentVersion < targetVersion) { 34 | upgrade() 35 | return false 36 | } else { 37 | downgrade() 38 | return false 39 | } 40 | } 41 | }), [db]) 42 | 43 | while (true) { 44 | const done = migrate.immediate(targetVersion, maxVersion) 45 | if (done) break 46 | } 47 | 48 | function upgrade(): void { 49 | const currentVersion = getDatabaseVersion(db) 50 | const targetVersion = currentVersion + 1 51 | 52 | const migration = migrations.find(x => x.version === targetVersion) 53 | assert(migration, `Cannot find migration for version ${targetVersion}`) 54 | 55 | try { 56 | if (isFunction(migration.up)) { 57 | migration.up(db) 58 | } else { 59 | db.exec(migration.up) 60 | } 61 | } catch (e) { 62 | console.error(`Upgrade from version ${currentVersion} to version ${targetVersion} failed.`) 63 | throw e 64 | } 65 | setDatabaseVersion(db, targetVersion) 66 | } 67 | 68 | function downgrade(): void { 69 | const currentVersion = getDatabaseVersion(db) 70 | const targetVersion = currentVersion - 1 71 | 72 | const migration = migrations.find(x => x.version === currentVersion) 73 | assert(migration, `Cannot find migration for version ${targetVersion}`) 74 | 75 | try { 76 | if (isFunction(migration.down)) { 77 | migration.down(db) 78 | } else { 79 | db.exec(migration.down) 80 | } 81 | } catch (e) { 82 | console.error(`Downgrade from version ${currentVersion} to version ${targetVersion} failed.`) 83 | throw e 84 | } 85 | setDatabaseVersion(db, targetVersion) 86 | } 87 | }) 88 | 89 | function getMaximumVersion(migrations: IMigration[]): number { 90 | return migrations.reduce((max, cur) => Math.max(cur.version, max), 0) 91 | } 92 | 93 | const getDatabaseVersion = withLazyStatic((db: Database): number => { 94 | const result = lazyStatic(() => db.prepare('PRAGMA user_version;'), [db]).get() as { user_version: number } 95 | return result['user_version'] 96 | }) 97 | 98 | function setDatabaseVersion(db: Database, version: number): void { 99 | // PRAGMA不支持变量 100 | db.exec(`PRAGMA user_version = ${ version }`) 101 | } 102 | -------------------------------------------------------------------------------- /tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2019" 4 | , "module": "CommonJS" 5 | , "strict": true 6 | , "noUnusedLocals": true 7 | , "noUnusedParameters": true 8 | , "baseUrl": "." 9 | , "paths": { 10 | "@src/*": ["src/*"] 11 | , "@test/*": ["__tests__/*"] 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base.json" 3 | , "compilerOptions": { 4 | "declaration": true 5 | , "removeComments": true 6 | , "sourceMap": true 7 | , "outDir": "lib" 8 | } 9 | , "include": [ 10 | "src" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base.json" 3 | , "include": [ 4 | "src" 5 | , "__tests__" 6 | ] 7 | , "exclude": [ 8 | "node_modules" 9 | , "lib" 10 | ] 11 | } 12 | --------------------------------------------------------------------------------