Compare commits

...

9 Commits

Author SHA1 Message Date
8c4c2a552c 2.0.8 2019-09-05 11:35:26 +02:00
eff9c6e6c9 fix(core): update 2019-09-05 11:35:26 +02:00
4c7a373d98 2.0.7 2019-01-15 00:20:05 +01:00
6b93a2e7ac fix(core): update 2019-01-15 00:20:05 +01:00
9c6487c779 2.0.6 2019-01-15 00:17:45 +01:00
e3f37f5027 fix(core): update 2019-01-15 00:17:44 +01:00
1152bb1138 2.0.5 2018-08-12 20:55:07 +02:00
9df7787450 2.0.4 2018-08-11 00:01:19 +02:00
3e81fdacad fix(CI): now building properly 2018-08-11 00:01:19 +02:00
13 changed files with 1171 additions and 531 deletions

View File

@ -1,4 +1,4 @@
# gitzone standard # gitzone ci_default
image: hosttoday/ht-docker-node:npmci image: hosttoday/ht-docker-node:npmci
cache: cache:
@ -26,6 +26,7 @@ mirror:
snyk: snyk:
stage: security stage: security
script: script:
- npmci npm prepare
- npmci command npm install -g snyk - npmci command npm install -g snyk
- npmci command npm install --ignore-scripts - npmci command npm install --ignore-scripts
- npmci command snyk test - npmci command snyk test
@ -33,24 +34,39 @@ snyk:
- docker - docker
- notpriv - notpriv
sast:
stage: security
image: registry.gitlab.com/hosttoday/ht-docker-dbase:npmci
variables:
DOCKER_DRIVER: overlay2
allow_failure: true
services:
- docker:stable-dind
script:
- npmci npm prepare
- npmci npm install
- npmci command npm run build
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
--volume "$PWD:/code"
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
artifacts:
reports:
sast: gl-sast-report.json
tags:
- docker
- priv
# ==================== # ====================
# test stage # test stage
# ==================== # ====================
testLEGACY:
stage: test
script:
- npmci node install legacy
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
allow_failure: true
testLTS: testLTS:
stage: test stage: test
script: script:
- npmci npm prepare
- npmci node install lts - npmci node install lts
- npmci npm install - npmci npm install
- npmci npm test - npmci npm test
@ -62,6 +78,7 @@ testLTS:
testSTABLE: testSTABLE:
stage: test stage: test
script: script:
- npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install
- npmci npm test - npmci npm test
@ -118,6 +135,7 @@ pages:
stage: metadata stage: metadata
script: script:
- npmci command npm install -g typedoc typescript - npmci command npm install -g typedoc typescript
- npmci npm prepare
- npmci npm install - npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/ - npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
tags: tags:
@ -130,13 +148,3 @@ pages:
paths: paths:
- public - public
allow_failure: true allow_failure: true
windowsCompatibility:
image: stefanscherer/node-windows:10-build-tools
stage: metadata
script:
- npm install & npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- windows
allow_failure: true

View File

@ -1,12 +1,7 @@
{ {
"npmts":{
"mode":"default",
"testConfig": {
"parallel": false
}
},
"npmci": { "npmci": {
"npmGlobalTools": [], "npmGlobalTools": [],
"npmAccessLevel": "public" "npmAccessLevel": "public",
"npmRegistryUrl": "registry.npmjs.org"
} }
} }

1519
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,13 @@
{ {
"name": "@pushrocks/taskbuffer", "name": "@pushrocks/taskbuffer",
"version": "2.0.3", "version": "2.0.8",
"private": false, "private": false,
"description": "flexible task management. TypeScript ready!", "description": "flexible task management. TypeScript ready!",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"scripts": { "scripts": {
"test": "tstest test/", "test": "(tstest test/)",
"build": "echo \"Not needed for now\"" "build": "(tsbuild)"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -27,17 +27,20 @@
}, },
"homepage": "https://gitlab.com/pushrocks/taskbuffer#readme", "homepage": "https://gitlab.com/pushrocks/taskbuffer#readme",
"dependencies": { "dependencies": {
"@pushrocks/lik": "^3.0.1", "@pushrocks/lik": "^3.0.11",
"@pushrocks/smartdelay": "^2.0.1", "@pushrocks/smartdelay": "^2.0.3",
"@pushrocks/smartlog": "^2.0.1", "@pushrocks/smartlog": "^2.0.19",
"@pushrocks/smartpromise": "^2.0.5", "@pushrocks/smartpromise": "^3.0.2",
"@types/cron": "^1.3.0", "@types/cron": "^1.7.1",
"cron": "^1.3.0", "cron": "^1.7.1",
"rxjs": "^6.2.2" "rxjs": "^6.5.3"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tstest": "^1.0.11", "@gitzone/tsbuild": "^2.1.17",
"@pushrocks/tapbundle": "^3.0.1", "@gitzone/tstest": "^1.0.24",
"@types/node": "^10.5.6" "@pushrocks/tapbundle": "^3.0.13",
"@types/node": "^12.7.4",
"tslint": "^5.19.0",
"tslint-config-prettier": "^1.18.0"
} }
} }

View File

@ -8,11 +8,8 @@ import * as smartdelay from '@pushrocks/smartdelay';
let testTask: taskbuffer.Task; let testTask: taskbuffer.Task;
let testPreTask = new taskbuffer.Task({ let testPreTask = new taskbuffer.Task({
taskFunction: function() { taskFunction: async () => {
let done = smartpromise.defer();
console.log('preTask executed'); console.log('preTask executed');
done.resolve();
return done.promise;
}, },
preTask: testTask preTask: testTask
}); });
@ -35,14 +32,14 @@ let task1 = new taskbuffer.Task({
let task2 = new taskbuffer.Task({ let task2 = new taskbuffer.Task({
name: 'Task 1', name: 'Task 1',
taskFunction: () => { taskFunction: async () => {
let done = smartpromise.defer(); const done = smartpromise.defer();
console.log('Task2 started'); console.log('Task2 started');
setTimeout(() => { setTimeout(() => {
console.log('Task2 executed'); console.log('Task2 executed');
done.resolve(); done.resolve();
}, 5000); }, 5000);
return done.promise; await done.promise;
} }
}); });

View File

@ -1,7 +1,7 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import taskbuffer = require('../ts/index'); import taskbuffer = require('../ts/index');
import * as smartq from 'smartq'; import * as smartpromise from '@pushrocks/smartpromise';
import * as smartdelay from '@pushrocks/smartdelay'; import * as smartdelay from '@pushrocks/smartdelay';
let task1Executed = false; let task1Executed = false;

View File

@ -1,11 +1,9 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import taskbuffer = require('../ts/index'); import taskbuffer = require('../ts/index');
import * as smartq from 'smartq';
import * as smartdelay from '@pushrocks/smartdelay'; import * as smartdelay from '@pushrocks/smartdelay';
let task1Executed = false; let task1Executed = false;
let task1 = new taskbuffer.Task({ const task1 = new taskbuffer.Task({
taskFunction: async () => { taskFunction: async () => {
await smartdelay.delayFor(2000); await smartdelay.delayFor(2000);
task1Executed = true; task1Executed = true;
@ -13,7 +11,7 @@ let task1 = new taskbuffer.Task({
}); });
let task2Executed = false; let task2Executed = false;
let task2 = new taskbuffer.Task({ const task2 = new taskbuffer.Task({
taskFunction: async () => { taskFunction: async () => {
await smartdelay.delayFor(2000); await smartdelay.delayFor(2000);
task2Executed = true; task2Executed = true;
@ -21,7 +19,7 @@ let task2 = new taskbuffer.Task({
}); });
let task3Executed = false; let task3Executed = false;
let task3 = new taskbuffer.Task({ const task3 = new taskbuffer.Task({
taskFunction: async () => { taskFunction: async () => {
await smartdelay.delayFor(2000); await smartdelay.delayFor(2000);
task3Executed = true; task3Executed = true;
@ -29,7 +27,7 @@ let task3 = new taskbuffer.Task({
}); });
tap.test('expect run in Parallel', async () => { tap.test('expect run in Parallel', async () => {
let testTaskparallel = new taskbuffer.Taskparallel({ const testTaskparallel = new taskbuffer.Taskparallel({
taskArray: [task1, task2, task3] taskArray: [task1, task2, task3]
}); });
await testTaskparallel.trigger(); await testTaskparallel.trigger();

View File

@ -6,7 +6,7 @@ import * as smartdelay from '@pushrocks/smartdelay';
let myTaskManager: taskbuffer.TaskManager; let myTaskManager: taskbuffer.TaskManager;
let taskRunCounter = 0; let taskRunCounter = 0;
let taskDone = smartpromise.defer(); const taskDone = smartpromise.defer();
tap.test('should create an instance of TaskManager', async () => { tap.test('should create an instance of TaskManager', async () => {
myTaskManager = new taskbuffer.TaskManager(); myTaskManager = new taskbuffer.TaskManager();

View File

@ -4,9 +4,9 @@ import taskbuffer = require('../ts/index');
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@pushrocks/smartpromise';
import * as smartdelay from '@pushrocks/smartdelay'; import * as smartdelay from '@pushrocks/smartdelay';
let flowTask1 = new taskbuffer.Task({ const flowTask1 = new taskbuffer.Task({
taskFunction: (x: number) => { taskFunction: (x: number) => {
let done = smartpromise.defer(); const done = smartpromise.defer();
console.log('flowTask1'); console.log('flowTask1');
console.log(x); console.log(x);
done.resolve(x); done.resolve(x);
@ -14,9 +14,9 @@ let flowTask1 = new taskbuffer.Task({
} }
}); });
let flowTaskBuffered = new taskbuffer.Task({ const flowTaskBuffered = new taskbuffer.Task({
taskFunction: (x: number) => { taskFunction: (x: number) => {
let done = smartpromise.defer(); const done = smartpromise.defer();
console.log('flowTask1'); console.log('flowTask1');
console.log(x); console.log(x);
done.resolve(x); done.resolve(x);
@ -26,9 +26,9 @@ let flowTaskBuffered = new taskbuffer.Task({
bufferMax: 1 bufferMax: 1
}); });
let flowTask2 = new taskbuffer.Task({ const flowTask2 = new taskbuffer.Task({
taskFunction: (x: number) => { taskFunction: (x: number) => {
let done = smartpromise.defer(); const done = smartpromise.defer();
console.log('flowTask2'); console.log('flowTask2');
console.log(x); console.log(x);
done.resolve(x); done.resolve(x);
@ -37,27 +37,27 @@ let flowTask2 = new taskbuffer.Task({
preTask: flowTask1 preTask: flowTask1
}); });
let flowTask3 = new taskbuffer.Taskchain({ const flowTask3 = new taskbuffer.Taskchain({
taskArray: [flowTask1, flowTask2] taskArray: [flowTask1, flowTask2]
}); });
tap.test('should let a value flow through a task', async () => { tap.test('should let a value flow through a task', async () => {
let result = await flowTask1.trigger(12); const result = await flowTask1.trigger(12);
expect(result).to.equal(12); expect(result).to.equal(12);
}); });
tap.test('expect values to flow between tasks', async () => { tap.test('expect values to flow between tasks', async () => {
let result = await flowTask2.trigger(12); const result = await flowTask2.trigger(12);
expect(result).to.equal(12); expect(result).to.equal(12);
}); });
tap.test('expect values to flow between tasks when buffered', async () => { tap.test('expect values to flow between tasks when buffered', async () => {
let result = await flowTaskBuffered.trigger(12); const result = await flowTaskBuffered.trigger(12);
expect(result).to.equal(12); expect(result).to.equal(12);
}); });
tap.test('expect values to flow between tasks in Taskchain', async () => { tap.test('expect values to flow between tasks in Taskchain', async () => {
let result = await flowTask3.trigger(12); const result = await flowTask3.trigger(12);
expect(result).to.equal(12); expect(result).to.equal(12);
}); });

View File

@ -100,7 +100,7 @@ export class Task {
if (stateArg === 'locked') { if (stateArg === 'locked') {
this._state = 'locked'; this._state = 'locked';
} else { } else {
plugins.smartlog.defaultLogger.error('state type ' + stateArg + ' could not be set'); plugins.smartlog.defaultLogger.log('error', 'state type ' + stateArg + ' could not be set');
} }
} }
} }

View File

@ -29,7 +29,7 @@ export class Taskchain extends Task {
if (typeof this.taskArray[taskCounter] !== 'undefined') { if (typeof this.taskArray[taskCounter] !== 'undefined') {
console.log(this.name + ' running: Task' + this.taskArray[taskCounter].name); console.log(this.name + ' running: Task' + this.taskArray[taskCounter].name);
this.taskArray[taskCounter].trigger(x).then(x => { this.taskArray[taskCounter].trigger(x).then(x => {
plugins.smartlog.defaultLogger.info(this.taskArray[taskCounter].name); plugins.smartlog.defaultLogger.log('info', this.taskArray[taskCounter].name);
taskCounter++; taskCounter++;
iterateTasks(x); iterateTasks(x);
}); });

View File

@ -5,7 +5,7 @@ import { Task } from './taskbuffer.classes.task';
import { Objectmap } from '@pushrocks/lik'; import { Objectmap } from '@pushrocks/lik';
export class TaskManager { export class TaskManager {
taskMap = new plugins.lik.Objectmap<Task>(); public taskMap = new plugins.lik.Objectmap<Task>();
private cronJobMap = new plugins.lik.Objectmap<ICronJob>(); private cronJobMap = new plugins.lik.Objectmap<ICronJob>();
constructor() { constructor() {
// nothing here // nothing here
@ -15,7 +15,7 @@ export class TaskManager {
* checks if a task is already present * checks if a task is already present
* @param taskNameArg * @param taskNameArg
*/ */
getTaskByName(taskNameArg): Task { public getTaskByName(taskNameArg): Task {
return this.taskMap.find(itemArg => { return this.taskMap.find(itemArg => {
return itemArg.name === taskNameArg; return itemArg.name === taskNameArg;
}); });
@ -25,7 +25,7 @@ export class TaskManager {
* adds a Task to the TaskManager * adds a Task to the TaskManager
* @param taskArg * @param taskArg
*/ */
addTask(taskArg: Task): void { public addTask(taskArg: Task): void {
if (!taskArg.name) { if (!taskArg.name) {
throw new Error('taskArg needs a name to be added to taskManager'); throw new Error('taskArg needs a name to be added to taskManager');
} }
@ -37,9 +37,9 @@ export class TaskManager {
* @param taskArg * @param taskArg
* @param cronStringArg * @param cronStringArg
*/ */
addAndScheduleTask(taskArg: Task, cronStringArg: string) { public addAndScheduleTask(taskArg: Task, cronStringArg: string) {
this.addTask(taskArg); this.addTask(taskArg);
let taskName = taskArg.name; const taskName = taskArg.name;
this.scheduleTaskByName(taskName, cronStringArg); this.scheduleTaskByName(taskName, cronStringArg);
} }
@ -47,8 +47,8 @@ export class TaskManager {
* triggers a task in the TaskManagerByName * triggers a task in the TaskManagerByName
* @param taskNameArg * @param taskNameArg
*/ */
triggerTaskByName(taskNameArg: string): Promise<any> { public triggerTaskByName(taskNameArg: string): Promise<any> {
let taskToTrigger = this.getTaskByName(taskNameArg); const taskToTrigger = this.getTaskByName(taskNameArg);
if (!taskToTrigger) { if (!taskToTrigger) {
throw new Error(`There is no task with the name of ${taskNameArg}`); throw new Error(`There is no task with the name of ${taskNameArg}`);
} }
@ -59,9 +59,9 @@ export class TaskManager {
* schedules the task by name * schedules the task by name
* @param taskNameArg * @param taskNameArg
*/ */
scheduleTaskByName(taskNameArg: string, cronStringArg: string) { public scheduleTaskByName(taskNameArg: string, cronStringArg: string) {
let taskToSchedule = this.getTaskByName(taskNameArg); const taskToSchedule = this.getTaskByName(taskNameArg);
let job = new plugins.cron.CronJob({ const job = new plugins.cron.CronJob({
cronTime: cronStringArg, cronTime: cronStringArg,
onTick: () => { onTick: () => {
this.triggerTaskByName(taskNameArg); this.triggerTaskByName(taskNameArg);
@ -75,8 +75,8 @@ export class TaskManager {
}); });
} }
descheduleTaskByName(taskNameArg: string) { public descheduleTaskByName(taskNameArg: string) {
let descheduledCron = this.cronJobMap.findOneAndRemove(itemArg => { const descheduledCron = this.cronJobMap.findOneAndRemove(itemArg => {
return itemArg.taskNameArg === taskNameArg; return itemArg.taskNameArg === taskNameArg;
}); });
descheduledCron.job.stop(); descheduledCron.job.stop();
@ -85,7 +85,7 @@ export class TaskManager {
* returns all schedules of a specific task * returns all schedules of a specific task
* @param taskNameArg * @param taskNameArg
*/ */
getSchedulesForTaskName(taskNameArg: string) {} public getSchedulesForTaskName(taskNameArg: string) {}
} }
export interface ICronJob { export interface ICronJob {

View File

@ -1,3 +1,17 @@
{ {
"extends": "tslint-config-standard" "extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
} }