Skip to content

Commit

Permalink
fix: several fixes to make the lib work on other ts projects
Browse files Browse the repository at this point in the history
  • Loading branch information
manast committed Sep 22, 2019
1 parent c72226b commit 3cac1b0
Show file tree
Hide file tree
Showing 21 changed files with 207 additions and 98 deletions.
18 changes: 16 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
"author": "Taskforce.sh Inc.",
"license": "MIT",
"scripts": {
"build": "tsc",
"build": "tsc && yarn copylua",
"copylua": "copyfiles -f ./src/commands/*.lua ./dist/commands",
"lint": "tslint --project tsconfig.json -c tslint.json 'src/**/*.ts'",
"test": "yarn lint && tsc && ts-mocha --paths 'src/**/test_*.ts' --exit",
"test:watch": "yarn lint && ts-mocha --paths 'src/**/test_*.ts' -w --watch-extensions ts",
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"precommit": "yarn lint",
"semantic-release": "semantic-release",
"prettier": "prettier --config package.json src/**/*.ts"
"prettier": "prettier --config package.json src/**/*.ts",
"semantic-release-prepare": "ts-node tools/semantic-release-prepare"
},
"devDependencies": {
"@commitlint/cli": "^8.1.0",
Expand All @@ -29,6 +31,7 @@
"@types/node-uuid": "^0.0.28",
"@types/sinon": "^7.0.13",
"chai": "^4.2.0",
"copyfiles": "^2.1.1",
"coveralls": "^3.0.2",
"delay": "^4.3.0",
"husky": "^3.0.3",
Expand All @@ -45,8 +48,19 @@
"tslint-config-prettier": "^1.18.0",
"tslint-eslint-rules": "^5.4.0",
"tslint-plugin-prettier": "^2.0.1",
"typedoc": "^0.15.0",
"typescript": "^3.2.2"
},
"config": {
"commitizen": {
"path": "node_modules/cz-conventional-changelog"
}
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"prettier": {
"singleQuote": true,
"trailingComma": "all",
Expand Down
4 changes: 2 additions & 2 deletions src/classes/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// TypeScript Version: 2.8

import { EventEmitter } from 'events';
import { QueueEvents, Worker, Queue, QueueScheduler, Job } from '@src/classes';
import { QueueEvents, Worker, Queue, QueueScheduler, Job } from './';
import {
JobsOptions,
QueueOptions,
Expand All @@ -29,7 +29,7 @@ import {
QueueSchedulerOptions,
WorkerOptions,
Processor,
} from '@src/interfaces';
} from '../interfaces';

type CommonOptions = QueueSchedulerOptions &
QueueOptions &
Expand Down
10 changes: 3 additions & 7 deletions src/classes/job.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { BackoffOptions } from '@src/interfaces/backoff-options';
import { WorkerOptions } from '@src/interfaces/worker-options';
import IORedis from 'ioredis';
import { debuglog } from 'util';
import { JobsOptions } from '../interfaces';
import { RetryErrors } from '../enums';
import { BackoffOptions, JobsOptions, WorkerOptions } from '../interfaces';
import { errorObject, isEmpty, tryCatch } from '../utils';
import { Backoffs } from './backoffs';
import { QueueBase } from './queue-base';
import { QueueEvents } from './queue-events';
import { Backoffs, QueueBase, QueueEvents } from './';
import { Scripts } from './scripts';
import { RetryErrors } from '@src/enums';

const logger = debuglog('bull');

Expand Down
2 changes: 1 addition & 1 deletion src/classes/queue-base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { QueueBaseOptions } from '@src/interfaces';
import { EventEmitter } from 'events';
import IORedis from 'ioredis';
import { QueueBaseOptions } from '../interfaces';
import { RedisConnection } from './redis-connection';

export class QueueBase extends EventEmitter {
Expand Down
2 changes: 1 addition & 1 deletion src/classes/queue-events.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QueueEventsOptions } from '@src/interfaces';
import { delay } from 'bluebird';
import { QueueEventsOptions } from '../interfaces';
import { array2obj } from '../utils';
import { QueueBase } from './queue-base';

Expand Down
6 changes: 3 additions & 3 deletions src/classes/queue-scheduler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { QueueBase } from './queue-base';
import { QueueSchedulerOptions } from '../interfaces';
import { array2obj } from '../utils';
import { QueueBase } from './';
import { Scripts } from './scripts';
import { array2obj } from '@src/utils';
import { QueueSchedulerOptions } from '@src/interfaces';

const MAX_TIMEOUT_MS = Math.pow(2, 31) - 1; // 32 bit signed

Expand Down
12 changes: 7 additions & 5 deletions src/classes/queue.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { JobsOptions, QueueOptions, RateLimiterOptions } from '@src/interfaces';
import { RepeatOptions } from '@src/interfaces/repeat-options';
import { get } from 'lodash';
import { v4 } from 'node-uuid';
import { Job } from './job';
import { QueueGetters } from './queue-getters';
import { Repeat } from './repeat';
import {
JobsOptions,
QueueOptions,
RateLimiterOptions,
RepeatOptions,
} from '../interfaces';
import { Job, QueueGetters, Repeat } from './';
import { Scripts } from './scripts';

export class Queue extends QueueGetters {
Expand Down
4 changes: 2 additions & 2 deletions src/classes/redis-connection.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RedisOptions, ConnectionOptions } from '@src/interfaces';
import IORedis from 'ioredis';
import * as semver from 'semver';
import { load } from '@src/commands';
import { load } from '../commands';
import { ConnectionOptions, RedisOptions } from '../interfaces';

export class RedisConnection {
static minimumVersion = '5.0.0';
Expand Down
8 changes: 3 additions & 5 deletions src/classes/repeat.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { QueueBase } from './queue-base';
import { Job } from './job';

import { createHash } from 'crypto';
import { RepeatOptions } from '@src/interfaces/repeat-options';
import { JobsOptions } from '@src/interfaces';
import { JobsOptions, RepeatOptions } from '../interfaces';
import { Job, QueueBase } from './';

const parser = require('cron-parser');

export class Repeat extends QueueBase {
Expand Down
13 changes: 6 additions & 7 deletions src/classes/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
/*eslint-env node */
'use strict';

import { QueueSchedulerOptions } from '@src/interfaces';
import { WorkerOptions } from '@src/interfaces/worker-options';
import IORedis from 'ioredis';
import { JobsOptions } from '../interfaces';
import {
JobsOptions,
QueueSchedulerOptions,
WorkerOptions,
} from '../interfaces';
import { array2obj } from '../utils';
import { Queue, QueueBase, QueueScheduler, Worker } from './';
import { Job, JobJson } from './job';
import { Queue } from './queue';
import { QueueBase } from './queue-base';
import { QueueScheduler } from './queue-scheduler';
import { Worker } from './worker';

export class Scripts {
static async isJobInList(
Expand Down
5 changes: 2 additions & 3 deletions src/classes/worker.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Processor, WorkerOptions } from '@src/interfaces/worker-options';
import * as Bluebird from 'bluebird';
import fs from 'fs';
import path from 'path';
import { Processor, WorkerOptions } from '../interfaces';
import { QueueBase, Repeat } from './';
import { ChildPool, pool } from './child-pool';
import { Job } from './job';
import { QueueBase } from './queue-base';
import { Repeat } from './repeat';
import sandbox from './sandbox';
import { Scripts } from './scripts';

Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export * from '@src/classes';
export * from '@src/interfaces';
export * from './classes';
export * from './commands';
export * from './enums';
export * from './interfaces';
18 changes: 9 additions & 9 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export * from './advanced-options';
export * from './backoff-options';
export * from './jobs-options';
export * from './queue-options';
export * from './rate-limiter-options';
export * from './redis-options';
export * from './repeat-options';
export * from './queue-scheduler-options';
export * from './worker-options';
export * from './advanced-options';
export * from './backoff-options';
export * from './jobs-options';
export * from './queue-options';
export * from './queue-scheduler-options';
export * from './rate-limiter-options';
export * from './redis-options';
export * from './repeat-options';
export * from './worker-options';
2 changes: 1 addition & 1 deletion src/interfaces/queue-options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JobsOptions } from '@src/interfaces';
import { JobsOptions } from '../interfaces';

import IORedis from 'ioredis';
import { ConnectionOptions } from './redis-options';
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/queue-scheduler-options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QueueBaseOptions } from '@src/interfaces';
import { QueueBaseOptions } from '../interfaces';

export interface QueueSchedulerOptions extends QueueBaseOptions {
maxStalledCount?: number;
Expand Down
6 changes: 2 additions & 4 deletions src/interfaces/worker-options.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { RateLimiterOptions } from './rate-limiter-options';
import { Job } from '@src/classes';
import { QueueBaseOptions } from './queue-options';
import { AdvancedOptions } from './advanced-options';
import { Job } from '../classes';
import { AdvancedOptions, QueueBaseOptions, RateLimiterOptions } from './';

export type Processor = (job: Job) => Promise<any>;

Expand Down
2 changes: 1 addition & 1 deletion src/test/test_bulk.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Queue, Worker, Job } from '@src/classes';
import { Queue, Worker, Job } from '../classes';
import { expect } from 'chai';
import IORedis from 'ioredis';
import { beforeEach, describe, it } from 'mocha';
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_child-pool.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { ChildPool } from '@src/classes';
import { ChildPool } from '../classes';

describe('Child pool', () => {
let pool: ChildPool;
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_clean.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Queue, QueueEvents, Worker } from '@src/classes';
import { Queue, QueueEvents, Worker } from '../classes';
import { delay } from 'bluebird';
import { expect } from 'chai';
import IORedis from 'ioredis';
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
"compilerOptions": {
"target": "ES2017",
"module": "commonjs",
"declaration": true,
"outDir": "dist",
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"strict": true,
"jsx": "preserve",
"importHelpers": true,
Expand Down
Loading

0 comments on commit 3cac1b0

Please sign in to comment.