From 1f920e2d8d0c3758add1d6da103b4c2f5d9e7469 Mon Sep 17 00:00:00 2001 From: Marc G Date: Thu, 15 Jul 2021 16:52:03 +0000 Subject: [PATCH] fix: build --- .gitignore | 3 ++- .../atomicGetIsEqualDelete.lua | 0 .../atomicGetIsEqualSetPExpire.lua | 0 package-lock.json | 25 ++++++++++++++++--- package.json | 8 +++--- .../index.ts => atomicGetIsEqualDelete.ts} | 2 +- ...index.ts => atomicGetIsEqualSetPExpire.ts} | 2 +- src/{index.ts => safeRedisLeader.ts} | 0 test/helper.ts | 4 +-- test/safe-redis-leader.e2e-spec.ts | 5 ++-- tsconfig.json | 19 ++++++-------- 11 files changed, 43 insertions(+), 25 deletions(-) rename src/atomicGetIsEqualDelete/index.lua => luas/atomicGetIsEqualDelete.lua (100%) rename src/atomicGetIsEqualSetPExpire/index.lua => luas/atomicGetIsEqualSetPExpire.lua (100%) rename src/{atomicGetIsEqualDelete/index.ts => atomicGetIsEqualDelete.ts} (87%) rename src/{atomicGetIsEqualSetPExpire/index.ts => atomicGetIsEqualSetPExpire.ts} (87%) rename src/{index.ts => safeRedisLeader.ts} (100%) diff --git a/.gitignore b/.gitignore index 6a5ae71..202673b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules .vscode -**/.DS_Store \ No newline at end of file +**/.DS_Store +dist \ No newline at end of file diff --git a/src/atomicGetIsEqualDelete/index.lua b/luas/atomicGetIsEqualDelete.lua similarity index 100% rename from src/atomicGetIsEqualDelete/index.lua rename to luas/atomicGetIsEqualDelete.lua diff --git a/src/atomicGetIsEqualSetPExpire/index.lua b/luas/atomicGetIsEqualSetPExpire.lua similarity index 100% rename from src/atomicGetIsEqualSetPExpire/index.lua rename to luas/atomicGetIsEqualSetPExpire.lua diff --git a/package-lock.json b/package-lock.json index e291bbc..ee34f8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ts-safe-redis-leader", - "version": "0.0.1", + "version": "0.0.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ts-safe-redis-leader", - "version": "0.0.1", + "version": "0.0.3", "license": "MIT", "dependencies": { "ioredis": "^4.27.6" @@ -27,7 +27,8 @@ "jest": "^27.0.6", "lodash": "^4.17.21", "ts-jest": "^27.0.3", - "typescript": "^4.3.5" + "typescript": "^4.3.5", + "uglify-js": "^3.13.10" } }, "node_modules/@babel/code-frame": { @@ -6090,6 +6091,18 @@ "node": ">=4.2.0" } }, + "node_modules/uglify-js": { + "version": "3.13.10", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.10.tgz", + "integrity": "sha512-57H3ACYFXeo1IaZ1w02sfA71wI60MGco/IQFjOqK+WtKoprh7Go2/yvd2HPtoJILO2Or84ncLccI4xoHMTSbGg==", + "dev": true, + "bin": { + "uglifyjs": "bin/uglifyjs" + }, + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/unbox-primitive": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", @@ -10985,6 +10998,12 @@ "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==", "dev": true }, + "uglify-js": { + "version": "3.13.10", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.10.tgz", + "integrity": "sha512-57H3ACYFXeo1IaZ1w02sfA71wI60MGco/IQFjOqK+WtKoprh7Go2/yvd2HPtoJILO2Or84ncLccI4xoHMTSbGg==", + "dev": true + }, "unbox-primitive": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", diff --git a/package.json b/package.json index 0708b63..2e0144c 100644 --- a/package.json +++ b/package.json @@ -2,12 +2,13 @@ "name": "ts-safe-redis-leader", "version": "0.0.3", "description": "Redis leader election implementation that does not have any race conditions in Typescript", - "main": "src/index.js", + "main": "dist/safeRedisLeader.js", "scripts": { "eslint": "eslint '{src,apps,libs,test}/**/*.ts' --fix", "test:debug": "node --inspect=0.0.0.0:9229 node_modules/.bin/jest --config ./test/jest-e2e.json --runInBand", "test": "node_modules/.bin/jest --config ./test/jest-e2e.json", - "prepublish": "npm run eslint && npm run test" + "prepublishOnly": "npm run eslint && npm run test && npm run build", + "build": "tsc" }, "author": "Marc Gagnon", "license": "MIT", @@ -44,6 +45,7 @@ "jest": "^27.0.6", "lodash": "^4.17.21", "ts-jest": "^27.0.3", - "typescript": "^4.3.5" + "typescript": "^4.3.5", + "uglify-js": "^3.13.10" } } diff --git a/src/atomicGetIsEqualDelete/index.ts b/src/atomicGetIsEqualDelete.ts similarity index 87% rename from src/atomicGetIsEqualDelete/index.ts rename to src/atomicGetIsEqualDelete.ts index 94a35d3..d7d5056 100644 --- a/src/atomicGetIsEqualDelete/index.ts +++ b/src/atomicGetIsEqualDelete.ts @@ -14,7 +14,7 @@ export async function atomicGetIsEqualDelete( id: string, ): Promise { if (!asyncRedis.getIsEqualDelete) { - const file = await readFile(`${__dirname}/index.lua`, "utf8"); + const file = await readFile(`${__dirname}/../luas/atomicGetIsEqualDelete.lua`, "utf8"); asyncRedis.defineCommand("getIsEqualDelete", { numberOfKeys: 1, diff --git a/src/atomicGetIsEqualSetPExpire/index.ts b/src/atomicGetIsEqualSetPExpire.ts similarity index 87% rename from src/atomicGetIsEqualSetPExpire/index.ts rename to src/atomicGetIsEqualSetPExpire.ts index 5b74d2f..3a68942 100644 --- a/src/atomicGetIsEqualSetPExpire/index.ts +++ b/src/atomicGetIsEqualSetPExpire.ts @@ -15,7 +15,7 @@ export async function atomicGetIsEqualSetPExpire( ms: number, ): Promise { if (!asyncRedis.getIsEqualSetPExpire) { - const file = await readFile(`${__dirname}/index.lua`, "utf8"); + const file = await readFile(`${__dirname}/../luas/atomicGetIsEqualSetPExpire.lua`, "utf8"); asyncRedis.defineCommand("getIsEqualSetPExpire", { numberOfKeys: 1, diff --git a/src/index.ts b/src/safeRedisLeader.ts similarity index 100% rename from src/index.ts rename to src/safeRedisLeader.ts diff --git a/test/helper.ts b/test/helper.ts index 1004330..dd54210 100644 --- a/test/helper.ts +++ b/test/helper.ts @@ -1,6 +1,6 @@ -/* eslint-disable no-async-promise-executor */ -import { EmitterEnum, SafeRedisLeader } from "../src"; +import { EmitterEnum, SafeRedisLeader } from "../src/safeRedisLeader"; +/* eslint-disable no-async-promise-executor */ export async function waitForElection(safeLeader: SafeRedisLeader): Promise { return new Promise(async (resolve) => { safeLeader.on(EmitterEnum.ELECTED, async () => { diff --git a/test/safe-redis-leader.e2e-spec.ts b/test/safe-redis-leader.e2e-spec.ts index 88e19a9..64cc2bf 100644 --- a/test/safe-redis-leader.e2e-spec.ts +++ b/test/safe-redis-leader.e2e-spec.ts @@ -1,10 +1,9 @@ -import * as Redis from "ioredis"; +import Redis from "ioredis"; -import { SafeRedisLeader } from "../src"; +import { SafeRedisLeader } from "../src/safeRedisLeader"; import { getLeaderIndex, sleep, waitForElection } from "./helper"; /* eslint-disable no-await-in-loop */ -jest.setTimeout(1000 * 15); describe("SafeRedisLeader", () => { let redisClients: Redis.Redis[] = []; diff --git a/tsconfig.json b/tsconfig.json index d8e88dc..3dc6dc0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,13 @@ { "compilerOptions": { - "module": "commonjs", "declaration": true, - "removeComments": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "allowSyntheticDefaultImports": true, - "target": "es2017", - "sourceMap": true, + "target": "es5", + "module": "commonjs", + "moduleResolution": "node", "outDir": "./dist", - "baseUrl": "./", - "incremental": true, - "skipLibCheck": true - } + "lib": ["ES6", "DOM"], + "typeRoots": ["node_modules/@types"], + "esModuleInterop": true + }, + "exclude": ["./node_modules", "./dist", "./test"], }