fix(core): update

This commit is contained in:
Philipp Kunz 2019-05-28 23:27:55 +02:00
parent b8a7f02b97
commit cfcba1aa01
15 changed files with 2116 additions and 3060 deletions

23
.gitignore vendored
View File

@ -1,3 +1,22 @@
node_modules/ .nogit/
pages/
# artifacts
coverage/
public/ public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
# custom

View File

@ -3,69 +3,123 @@ image: hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
- .yarn/ - .npmci_cache/
key: "$CI_BUILD_STAGE" key: "$CI_BUILD_STAGE"
stages: stages:
- security
- test - test
- release - release
- trigger - metadata
- pages
testLEGACY: # ====================
stage: test # security stage
# ====================
mirror:
stage: security
script: script:
- npmci test legacy - npmci git mirror
coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
allow_failure: true - notpriv
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- docker
- notpriv
# ====================
# test stage
# ====================
testLTS: testLTS:
stage: test stage: test
script: script:
- npmci test lts - npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
testSTABLE: testSTABLE:
stage: test stage: test
script: script:
- npmci test stable - npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
release: release:
stage: release stage: release
script: script:
- npmci publish - npmci node install stable
- npmci npm publish
only: only:
- tags - tags
tags: tags:
- docker - docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
image: docker:stable
allow_failure: true
services:
- docker:stable-dind
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--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:
- docker
- priv
trigger: trigger:
stage: trigger stage: metadata
script: script:
- npmci trigger - npmci trigger
only: only:
- tags - tags
tags: tags:
- docker - docker
- notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmci image: hosttoday/ht-docker-node:npmci
stage: pages stage: metadata
script: script:
- npmci command yarn global add npmpage - npmci command npm install -g @gitzone/tsdoc
- npmci command npmpage --publish gitlab - npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags: tags:
- docker - docker
- notpriv
only: only:
- tags - tags
artifacts: artifacts:
expire_in: 1 week expire_in: 1 week
paths: paths:
- public - public
allow_failure: true

View File

@ -1,29 +1,35 @@
# smartbrowser # @pushrocks/smartbrowser
wraps browser-sync puppeteer wrapper for easy tasks
## Availabililty ## Availabililty and Links
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartbrowser) * [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartbrowser)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartbrowser) * [gitlab.com (source)](https://gitlab.com/pushrocks/smartbrowser)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartbrowser) * [github.com (source mirror)](https://github.com/pushrocks/smartbrowser)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartbrowser/) * [docs (typedoc)](https://pushrocks.gitlab.io/smartbrowser/)
## Status for master ## Status for master
[![build status](https://GitLab.com/pushrocks/smartbrowser/badges/master/build.svg)](https://GitLab.com/pushrocks/smartbrowser/commits/master) [![build status](https://gitlab.com/pushrocks/smartbrowser/badges/master/build.svg)](https://gitlab.com/pushrocks/smartbrowser/commits/master)
[![coverage report](https://GitLab.com/pushrocks/smartbrowser/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartbrowser/commits/master) [![coverage report](https://gitlab.com/pushrocks/smartbrowser/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartbrowser/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/smartbrowser.svg)](https://www.npmjs.com/package/smartbrowser) [![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartbrowser.svg)](https://www.npmjs.com/package/@pushrocks/smartbrowser)
[![Dependency Status](https://david-dm.org/pushrocks/smartbrowser.svg)](https://david-dm.org/pushrocks/smartbrowser) [![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartbrowser/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartbrowser)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartbrowser/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartbrowser/master/dependencies/npm) [![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartbrowser/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartbrowser) [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/) [![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
[![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 ## Usage
Use TypeScript for best in class instellisense. Use TypeScript for best in class instellisense.
For further information read the linked docs at the top of this README. For further information read the linked docs at the top of this README.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) > MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html) > | 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) [![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
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://maintainedby.lossless.com)

32
dist/index.d.ts vendored
View File

@ -1,32 +0,0 @@
/// <reference types="browser-sync" />
import * as plugins from './smartbrowser.plugins';
/**
* the options interface of a Smartbrowser instance
*/
export interface ISmartbrowserOptions {
webroot: string;
watchFiles: string[];
}
/**
* Type of status that a bsInstance can have
*/
export declare type bsStatus = 'idle' | 'starting' | 'running';
/**
* class smartbrowser controls a browser-sync instance for you
*/
export declare class Smartbrowser {
bsInstance: plugins.browserSync.BrowserSyncInstance;
bsConfig: plugins.browserSync.Options;
bsStatus: bsStatus;
bsStarted: Promise<void>;
constructor(optionsArg: ISmartbrowserOptions);
/**
* starts the server and returns the browserSync instance in a resolved Promise
*/
start(): Promise<plugins.browserSync.BrowserSyncInstance>;
/**
* stops the smartbrowser instance
*/
stop(): Promise<void>;
reload(): Promise<void>;
}

63
dist/index.js vendored
View File

@ -1,63 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartbrowser.plugins");
/**
* class smartbrowser controls a browser-sync instance for you
*/
class Smartbrowser {
constructor(optionsArg) {
this.bsInstance = plugins.browserSync.create();
this.bsConfig = {
server: {}
};
this.bsStatus = 'idle';
this.bsConfig.server.baseDir = optionsArg.webroot;
this.bsConfig.files = optionsArg.watchFiles;
}
/**
* starts the server and returns the browserSync instance in a resolved Promise
*/
start() {
return __awaiter(this, void 0, void 0, function* () {
let done = plugins.smartq.defer();
if (this.bsStatus === 'idle') {
this.bsStatus = 'starting';
let localDone = plugins.smartq.defer();
this.bsStarted = localDone.promise;
this.bsInstance.init(this.bsConfig, () => {
this.bsStatus = 'running';
localDone.resolve();
done.resolve(this.bsInstance);
});
}
else {
this.bsStarted.then(() => { done.resolve(this.bsInstance); });
}
return yield done.promise;
});
}
/**
* stops the smartbrowser instance
*/
stop() {
return __awaiter(this, void 0, void 0, function* () {
this.bsInstance.exit();
this.bsStatus = 'idle';
});
}
reload() {
return __awaiter(this, void 0, void 0, function* () {
this.bsInstance.reload();
});
}
}
exports.Smartbrowser = Smartbrowser;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsa0RBQWlEO0FBZ0JqRDs7R0FFRztBQUNIO0lBT0UsWUFBYSxVQUFnQztRQU43QyxlQUFVLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLEVBQUUsQ0FBQTtRQUN6QyxhQUFRLEdBQWdDO1lBQ3RDLE1BQU0sRUFBRSxFQUFFO1NBQ1gsQ0FBQTtRQUNELGFBQVEsR0FBYSxNQUFNLENBQUE7UUFHekIsSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsT0FBTyxHQUFHLFVBQVUsQ0FBQyx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LElBQUk7O1lBQ1IsSUFBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLEVBQUUsQ0FBQTtZQUN0QixJQUFJLENBQUMsUUFBUSxHQUFHLE1BQU0sQ0FBQTtRQUN4QixDQUFDO0tBQUE7SUFFSyxNQUFNOztZQUNWLElBQUksQ0FBQyxVQUFVLENBQUMsTUFBTSxFQUFFLENBQUE7UUFDMUIsQ0FBQztLQUFBO0NBQ0Y7QUEzQ0Qsb0NBMkNDIn0=

View File

@ -1,3 +0,0 @@
import 'typings-global';
export import browserSync = require('browser-sync');
export import smartq = require('smartq');

View File

@ -1,6 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global");
exports.browserSync = require("browser-sync");
exports.smartq = require("smartq");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRicm93c2VyLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGJyb3dzZXIucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2Qiw4Q0FBbUQ7QUFDbkQsbUNBQXdDIn0=

View File

@ -3,5 +3,15 @@
"globalNpmTools": [ "globalNpmTools": [
"npmts" "npmts"
] ]
},
"gitzone": {
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartbrowser",
"shortDescription": "puppeteer wrapper for easy tasks",
"npmPackagename": "@pushrocks/smartbrowser",
"license": "MIT"
}
} }
} }

1918
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,12 @@
{ {
"name": "smartbrowser", "name": "@pushrocks/smartbrowser",
"version": "1.0.5", "version": "1.0.5",
"description": "wraps browser-sync", "description": "simplified puppeteer",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"scripts": { "scripts": {
"test": "(npmts)" "test": "(npmts)",
"build": "echo \"Not needed for now\""
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -18,13 +19,24 @@
}, },
"homepage": "https://gitlab.com/pushrocks/smartbrowser#README", "homepage": "https://gitlab.com/pushrocks/smartbrowser#README",
"dependencies": { "dependencies": {
"@types/browser-sync": "0.0.34", "puppeteer": "^1.17.0"
"browser-sync": "^2.18.8",
"smartq": "^1.1.1",
"typings-global": "^1.0.14"
}, },
"devDependencies": { "devDependencies": {
"smartdelay": "^1.0.1", "@gitzone/tsbuild": "^2.1.11",
"tapbundle": "^1.0.5" "@gitzone/tstest": "^1.0.24",
} "@pushrocks/tapbundle": "^3.0.9",
"tslint": "^5.16.0",
"tslint-config-prettier": "^1.18.0"
},
"private": true,
"files": [
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"assets/*",
"cli.js",
"npmextra.json",
"readme.md"
]
} }

View File

@ -1,29 +1,32 @@
import { tap, expect } from 'tapbundle' import { tap, expect } from 'tapbundle';
import * as smartdelay from 'smartdelay' import * as smartdelay from 'smartdelay';
import * as smartbrowser from '../dist/index' import * as smartbrowser from '../dist/index';
let testSmartBrowser: smartbrowser.Smartbrowser let testSmartBrowser: smartbrowser.Smartbrowser;
tap
tap.test('should instanstiate a new browser ', async () => { .test('should instanstiate a new browser ', async () => {
testSmartBrowser = new smartbrowser.Smartbrowser({ testSmartBrowser = new smartbrowser.Smartbrowser({
webroot: './test/assets/', webroot: './test/assets/',
watchFiles: ['./test/assets/'] watchFiles: ['./test/assets/']
});
return expect(testSmartBrowser).to.be.instanceof(smartbrowser.Smartbrowser);
}) })
return expect(testSmartBrowser).to.be.instanceof(smartbrowser.Smartbrowser) .catch(tap.threw);
}).catch(tap.threw)
tap.test('should start the browser ', async () => { tap
return await expect(testSmartBrowser.start()).to.eventually.be.fulfilled .test('should start the browser ', async () => {
}).catch(tap.threw) return await expect(testSmartBrowser.start()).to.eventually.be.fulfilled;
})
.catch(tap.threw);
tap.test('should stop the browser ', async () => { tap.test('should stop the browser ', async () => {
return await smartdelay.delayFor(2000).then(() => { return await smartdelay.delayFor(2000).then(() => {
return expect(testSmartBrowser.stop()).to.eventually.be.fulfilled return expect(testSmartBrowser.stop()).to.eventually.be.fulfilled;
}) });
}) });
tap.test('should exit correctly', async () => { tap.test('should exit correctly', async () => {
smartdelay.delayFor(2000).then(() => { smartdelay.delayFor(2000).then(() => {
process.exit(0) process.exit(0);
}) });
}) });

View File

@ -1,63 +1,5 @@
import * as plugins from './smartbrowser.plugins' import * as plugins from './smartbrowser.plugins';
/** export class SmartBrowser {
* the options interface of a Smartbrowser instance
*/
export interface ISmartbrowserOptions {
webroot: string
watchFiles: string[]
} }
/**
* Type of status that a bsInstance can have
*/
export type bsStatus = 'idle' | 'starting' | 'running'
/**
* class smartbrowser controls a browser-sync instance for you
*/
export class Smartbrowser {
bsInstance = plugins.browserSync.create()
bsConfig: plugins.browserSync.Options = {
server: {}
}
bsStatus: bsStatus = 'idle'
bsStarted: Promise<void>
constructor (optionsArg: ISmartbrowserOptions) {
this.bsConfig.server.baseDir = optionsArg.webroot
this.bsConfig.files = optionsArg.watchFiles
}
/**
* starts the server and returns the browserSync instance in a resolved Promise
*/
async start (): Promise<plugins.browserSync.BrowserSyncInstance> {
let done = plugins.smartq.defer<plugins.browserSync.BrowserSyncInstance>()
if (this.bsStatus === 'idle') {
this.bsStatus = 'starting'
let localDone = plugins.smartq.defer<void>()
this.bsStarted = localDone.promise
this.bsInstance.init(this.bsConfig, () => {
this.bsStatus = 'running'
localDone.resolve()
done.resolve(this.bsInstance)
})
} else {
this.bsStarted.then(() => { done.resolve(this.bsInstance) })
}
return await done.promise
}
/**
* stops the smartbrowser instance
*/
async stop (): Promise<void> {
this.bsInstance.exit()
this.bsStatus = 'idle'
}
async reload (): Promise<void> {
this.bsInstance.reload()
}
}

View File

@ -1,3 +1,3 @@
import 'typings-global' import 'typings-global';
export import browserSync = require('browser-sync') export import browserSync = require('browser-sync');
export import smartq = require('smartq') export import smartq = require('smartq');

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

2818
yarn.lock

File diff suppressed because it is too large Load Diff