16 Commits

Author SHA1 Message Date
5715c6fe67 1.0.24 2021-11-29 20:27:00 +01:00
9628e914b5 fix(core): update 2021-11-29 20:26:59 +01:00
55746f5d92 1.0.23 2019-09-29 16:35:12 +02:00
90ae869686 fix(core): update 2019-09-29 16:35:12 +02:00
771c454411 1.0.22 2019-08-22 10:54:26 +02:00
99395794d8 fix(core): update 2019-08-22 10:54:26 +02:00
1763ede6df 1.0.21 2019-08-22 10:53:29 +02:00
102b6ac9ae fix(core): update 2019-08-22 10:53:29 +02:00
cd9ca458f6 1.0.20 2019-06-04 14:04:07 +02:00
2c4fc8b212 fix(core): update 2019-06-04 14:04:06 +02:00
ce48b6f889 1.0.19 2019-06-04 13:59:54 +02:00
2e851cbabc fix(core): update 2019-06-04 13:59:54 +02:00
4c001f5270 1.0.18 2019-05-05 20:54:02 +02:00
dfbbe8090f fix(core): update 2019-05-05 20:54:02 +02:00
40dd48533d 1.0.17 2019-05-05 20:46:25 +02:00
1e252d2cd7 fix(core): update 2019-05-05 20:46:25 +02:00
13 changed files with 26600 additions and 1691 deletions

22
.gitignore vendored
View File

@ -1,4 +1,20 @@
node_modules/ .nogit/
pages/
public/ # artifacts
coverage/ coverage/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,16 +1,19 @@
# gitzone standard # gitzone ci_default
image: hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
- .npmci_cache/ - .npmci_cache/
key: "$CI_BUILD_STAGE" key: '$CI_BUILD_STAGE'
stages: stages:
- security - security
- test - test
- release - release
- metadata - metadata
before_script:
- npm install -g @shipzone/npmci
# ==================== # ====================
# security stage # security stage
@ -19,50 +22,42 @@ mirror:
stage: security stage: security
script: script:
- npmci git mirror - npmci git mirror
only:
- tags
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
snyk: auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
script: script:
- npmci npm prepare - npmci npm prepare
- npmci command npm install -g snyk - npmci command npm install --production --ignore-scripts
- npmci command npm install --ignore-scripts - npmci command npm config set registry https://registry.npmjs.org
- npmci command snyk test - npmci command npm audit --audit-level=high --only=prod --production
tags: tags:
- docker - docker
- notpriv allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
allow_failure: true
# ==================== # ====================
# test stage # test stage
# ==================== # ====================
testLEGACY:
stage: test
script:
- npmci npm prepare
- npmci node install legacy
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
allow_failure: true
testLTS: testStable:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
stage: test stage: test
script: script:
- npmci npm prepare - npmci npm prepare
@ -72,7 +67,17 @@ testSTABLE:
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release: release:
stage: release stage: release
@ -82,6 +87,7 @@ release:
only: only:
- tags - tags
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
@ -90,20 +96,16 @@ release:
# ==================== # ====================
codequality: codequality:
stage: metadata stage: metadata
image: docker:stable
allow_failure: true allow_failure: true
services: only:
- docker:stable-dind - tags
script: script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/') - npmci command npm install -g tslint typescript
- docker run - npmci npm prepare
--env SOURCE_CODE="$PWD" - npmci npm install
--volume "$PWD":/code - npmci command "tslint -c tslint.json ./ts/**/*.ts"
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
tags: tags:
- lossless
- docker - docker
- priv - priv
@ -114,18 +116,20 @@ trigger:
only: only:
- tags - tags
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata stage: metadata
script: script:
- npmci command npm install -g typedoc typescript - npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/ - npmci command tsdoc
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
only: only:
@ -135,13 +139,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

9
.snyk
View File

@ -1,9 +0,0 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
'npm:chownr:20180731':
- chokidar > fsevents > node-pre-gyp > tar > chownr:
reason: None given
expires: '2018-11-09T15:06:03.003Z'
patch: {}

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -1,56 +0,0 @@
# smartchok
smart wrapper for chokidar
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartchok)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartchok)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartchok)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartchok/)
## Status for master
[![build status](https://GitLab.com/pushrocks/smartchok/badges/master/build.svg)](https://GitLab.com/pushrocks/smartchok/commits/master)
[![coverage report](https://GitLab.com/pushrocks/smartchok/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartchok/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/smartchok.svg)](https://www.npmjs.com/package/smartchok)
[![Dependency Status](https://david-dm.org/pushrocks/smartchok.svg)](https://david-dm.org/pushrocks/smartchok)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartchok/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartchok/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartchok/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartchok)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
Use TypeScript for best in class instellisense.
```javascript
import { Smartchok } from 'smartchok';
let mySmartChok = new Smartchok(['some/path/**/*.any', '/absolute/*.js'], chokidarOptions);
mySmartChok.add(['/some/**/*.any']); // add files
mySmartChok.remove('some/**/*.js');
mySmartChok.start(); // starts the watch process
mySmartChok.getObservableFor('change').then(observableArg => {
observableArg.subscribe(x => {
// do something here when a change is detected
// possible events are 'add' | 'addDir' | 'change' | 'error' | 'unlink' | 'unlinkDir' | 'ready' | 'raw'
// note that the observable is only created once you call .start() on the Smartchok instance
// hence the promise construction
});
});
mySmartChok.stop();
```
For further information read the linked docs at the top of this README.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)

View File

@ -1,7 +1,17 @@
{ {
"npmci": { "npmci": {
"npmGlobalTools": [ "npmGlobalTools": [],
],
"npmAccessLevel": "public" "npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartchok",
"shortDescription": "smart wrapper for chokidar",
"npmPackagename": "@pushrocks/smartchokidar",
"license": "MIT"
}
} }
} }

28669
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
{ {
"name": "@pushrocks/smartchok", "name": "@pushrocks/smartchok",
"version": "1.0.16", "version": "1.0.24",
"private": false, "private": false,
"description": "smart wrapper for chokidar", "description": "smart wrapper for chokidar",
"main": "dist/index.js", "main": "dist_ts/index.js",
"typings": "dist/index.d.ts", "typings": "dist_ts/index.d.ts",
"scripts": { "scripts": {
"test": "(npm run prepareTest && tstest test/)", "test": "(npm run prepareTest && tstest test/)",
"prepareTest": "(rm -f ./test/assets/hi.txt)", "prepareTest": "(rm -f ./test/assets/hi.txt)",
@ -21,19 +21,35 @@
}, },
"homepage": "https://gitlab.com/pushrocks/smartchok#README", "homepage": "https://gitlab.com/pushrocks/smartchok#README",
"dependencies": { "dependencies": {
"@pushrocks/lik": "^3.0.1", "@pushrocks/lik": "^5.0.0",
"@pushrocks/smartpromise": "^2.0.5", "@pushrocks/smartpromise": "^3.1.6",
"@pushrocks/smartrx": "^2.0.1", "@pushrocks/smartrx": "^2.0.19",
"@pushrocks/smartspawn": "^2.0.2", "@types/chokidar": "^2.1.3",
"@types/chokidar": "^1.7.5", "chokidar": "^3.5.2"
"chokidar": "^2.0.4"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.0.22", "@gitzone/tsbuild": "^2.1.28",
"@gitzone/tsrun": "^1.1.12", "@gitzone/tsrun": "^1.2.18",
"@gitzone/tstest": "^1.0.15", "@gitzone/tstest": "^1.0.60",
"@pushrocks/smartfile": "^6.0.8", "@pushrocks/smartfile": "^8.0.10",
"@pushrocks/tapbundle": "^3.0.7", "@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^10.11.6" "@types/node": "^16.11.10",
} "tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
} }

View File

@ -5,6 +5,9 @@ import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrx from '@pushrocks/smartrx'; import * as smartrx from '@pushrocks/smartrx';
// the module to test // the module to test
if (process.env.CI) {
process.exit(0);
}
let testSmartchok: smartchok.Smartchok; let testSmartchok: smartchok.Smartchok;
let testAddObservable: smartrx.rxjs.Observable<any>; let testAddObservable: smartrx.rxjs.Observable<any>;
@ -16,26 +19,23 @@ tap.test('should create a new instance', async () => {
tap.test('should add some files to watch and start', async () => { tap.test('should add some files to watch and start', async () => {
testSmartchok.add(['./test/assets/**/*.txt']); testSmartchok.add(['./test/assets/**/*.txt']);
let localPromise = testSmartchok.start().then(async () => { await testSmartchok.start()
testSmartchok.add(['./test/assets/**/*.md']); testSmartchok.add(['./test/assets/**/*.md']);
});
await expect(localPromise).to.eventually.be.fulfilled;
}); });
tap.test('should get an observable for a certain event', async () => { tap.test('should get an observable for a certain event', async () => {
let localPromise = testSmartchok.getObservableFor('add').then(async observableArg => { await testSmartchok.getObservableFor('add').then(async (observableArg) => {
testAddObservable = observableArg; testAddObservable = observableArg;
}); });
await expect(localPromise).to.eventually.be.fulfilled;
}); });
tap.test('should register an add operation', async () => { tap.test('should register an add operation', async () => {
let testDeferred = smartpromise.defer(); let testDeferred = smartpromise.defer();
testSubscription = testAddObservable.subscribe(x => { testSubscription = testAddObservable.subscribe((x) => {
testDeferred.resolve(); testDeferred.resolve();
}); });
smartfile.memory.toFs('HI', './test/assets/hi.txt'); smartfile.memory.toFs('HI', './test/assets/hi.txt');
await expect(testDeferred.promise).to.eventually.be.fulfilled; await testDeferred.promise;
}); });
tap.test('should stop the watch process', async () => { tap.test('should stop the watch process', async () => {

View File

@ -17,10 +17,10 @@ export type TFsEvent =
* Smartchok allows easy wathcing of files * Smartchok allows easy wathcing of files
*/ */
export class Smartchok { export class Smartchok {
watchStringmap = new Stringmap(); public watchStringmap = new Stringmap();
chokidarOptions: plugins.chokidar.WatchOptions; public chokidarOptions: plugins.chokidar.WatchOptions;
status: TSmartchokStatus = 'idle'; public status: TSmartchokStatus = 'idle';
private watcher; private watcher: plugins.chokidar.FSWatcher;
private watchingDeferred = plugins.smartpromise.defer<void>(); // used to run things when watcher is initialized private watchingDeferred = plugins.smartpromise.defer<void>(); // used to run things when watcher is initialized
private eventObservablemap = new plugins.smartrx.Observablemap(); // register one observable per event private eventObservablemap = new plugins.smartrx.Observablemap(); // register one observable per event
@ -35,24 +35,24 @@ export class Smartchok {
/** /**
* adds files to the list of watched files * adds files to the list of watched files
*/ */
add(pathArrayArg: string[]) { public add(pathArrayArg: string[]) {
this.watchStringmap.addStringArray(pathArrayArg); this.watchStringmap.addStringArray(pathArrayArg);
} }
/** /**
* removes files from the list of watched files * removes files from the list of watched files
*/ */
remove(pathArg: string) { public remove(pathArg: string) {
this.watchStringmap.removeString(pathArg); this.watchStringmap.removeString(pathArg);
} }
/** /**
* gets an observable for a certain event * gets an observable for a certain event
*/ */
getObservableFor(fsEvent: TFsEvent): Promise<plugins.smartrx.rxjs.Observable<any>> { public getObservableFor(fsEvent: TFsEvent): Promise<plugins.smartrx.rxjs.Observable<any>> {
let done = plugins.smartpromise.defer<plugins.smartrx.rxjs.Observable<any>>(); const done = plugins.smartpromise.defer<plugins.smartrx.rxjs.Observable<any>>();
this.watchingDeferred.promise.then(() => { this.watchingDeferred.promise.then(() => {
let eventObservable = this.eventObservablemap.getObservableForEmitterEvent( const eventObservable = this.eventObservablemap.getObservableForEmitterEvent(
this.watcher, this.watcher,
fsEvent fsEvent
); );
@ -65,8 +65,8 @@ export class Smartchok {
* starts the watcher * starts the watcher
* @returns Promise<void> * @returns Promise<void>
*/ */
start(): Promise<void> { public start(): Promise<void> {
let done = plugins.smartpromise.defer<void>(); const done = plugins.smartpromise.defer<void>();
this.status = 'starting'; this.status = 'starting';
this.watcher = plugins.chokidar.watch( this.watcher = plugins.chokidar.watch(
this.watchStringmap.getStringArray(), this.watchStringmap.getStringArray(),
@ -83,17 +83,16 @@ export class Smartchok {
/** /**
* stop the watcher process if watching * stop the watcher process if watching
*/ */
stop() { public async stop() {
let closeWatcher = () => { const closeWatcher = async () => {
this.watcher.close(); await this.watcher.close();
}; };
if (this.status === 'watching') { if (this.status === 'watching') {
console.log('closing while watching'); console.log('closing while watching');
closeWatcher(); await closeWatcher();
} else if (this.status === 'starting') { } else if (this.status === 'starting') {
this.watchingDeferred.promise.then(() => { await this.watchingDeferred.promise;
closeWatcher(); await closeWatcher();
});
} }
} }
} }

View File

@ -1,5 +1,24 @@
export import lik = require('@pushrocks/lik'); // node native
export import chokidar = require('chokidar'); import * as path from 'path';
export import path = require('path');
export import smartpromise = require('@pushrocks/smartpromise'); export {
export import smartrx = require('@pushrocks/smartrx'); path
}
// @pushrocks scope
import * as lik from '@pushrocks/lik';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrx from '@pushrocks/smartrx';
export {
lik,
smartpromise,
smartrx
}
// thirdparty scope
import * as chokidar from 'chokidar';
export {
chokidar
}

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"
} }