update to latest standards

This commit is contained in:
Philipp Kunz 2017-04-09 12:35:53 +02:00
parent c9fd889dd3
commit 43bc078ace
15 changed files with 2958 additions and 193 deletions

View File

@ -1,19 +1,31 @@
image: hosttoday/ht-docker-node:npmts # gitzone standard
image: hosttoday/ht-docker-node:npmci
cache:
paths:
- .yarn/
key: "$CI_BUILD_STAGE"
stages: stages:
- test - test
- release - release
- trigger
- pages
testLEGACY: testLEGACY:
stage: test stage: test
script: script:
- npmci test legacy - npmci test legacy
coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
allow_failure: true allow_failure: true
testLTS: testLTS:
stage: test stage: test
script: script:
- npmci test lts - npmci test lts
coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
@ -21,14 +33,39 @@ testSTABLE:
stage: test stage: test
script: script:
- npmci test stable - npmci test stable
coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
release: release:
stage: release stage: release
environment: npm_registry
script: script:
- npmci publish - npmci publish
only: only:
- tags - tags
tags: tags:
- docker - docker
trigger:
stage: trigger
script:
- npmci trigger
only:
- tags
tags:
- docker
pages:
image: hosttoday/ht-docker-node:npmci
stage: pages
script:
- npmci command yarn global add npmpage
- npmci command npmpage --publish gitlab
tags:
- docker
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public

View File

@ -1,15 +1,16 @@
# smartbrowser # smartbrowser
easy class API for serving stacks during development with `browser-sync`. wraps browser-sync
## Availabililty ## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartbrowser) [![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartbrowser)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartbrowser) [![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartbrowser)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartbrowser) [![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartbrowser)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartbrowser/) [![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](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)
[![Dependency Status](https://david-dm.org/pushrocks/smartbrowser.svg)](https://david-dm.org/pushrocks/smartbrowser) [![Dependency Status](https://david-dm.org/pushrocks/smartbrowser.svg)](https://david-dm.org/pushrocks/smartbrowser)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartbrowser/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartbrowser/master/dependencies/npm) [![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartbrowser/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartbrowser/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartbrowser/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartbrowser) [![bitHound Code](https://www.bithound.io/github/pushrocks/smartbrowser/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartbrowser)
@ -17,4 +18,12 @@ easy class API for serving stacks during development with `browser-sync`.
[![node](https://img.shields.io/badge/node->=%206.x.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/) [![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks) ## Usage
Use TypeScript for best in class instellisense.
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)

File diff suppressed because one or more lines are too long

View File

@ -1,88 +0,0 @@
TN:
SF:/Users/philkunz/gitlab/pushrocks/smartbrowser/dist/index.js
FN:3,(anonymous_1)
FN:3,defineProperties
FN:3,(anonymous_3)
FN:5,_classCallCheck
FN:12,(anonymous_5)
FN:13,Smartbrowser
FN:31,start
FN:36,(anonymous_8)
FN:40,(anonymous_9)
FN:47,(anonymous_10)
FN:59,stop
FNF:11
FNH:10
FNDA:1,(anonymous_1)
FNDA:1,defineProperties
FNDA:1,(anonymous_3)
FNDA:1,_classCallCheck
FNDA:1,(anonymous_5)
FNDA:1,Smartbrowser
FNDA:1,start
FNDA:1,(anonymous_8)
FNDA:1,(anonymous_9)
FNDA:0,(anonymous_10)
FNDA:1,stop
DA:3,2
DA:5,1
DA:7,1
DA:12,1
DA:13,1
DA:14,1
DA:16,1
DA:17,1
DA:20,1
DA:21,1
DA:22,1
DA:29,1
DA:32,1
DA:34,1
DA:35,1
DA:36,1
DA:37,1
DA:38,1
DA:39,1
DA:40,1
DA:41,1
DA:42,1
DA:43,1
DA:47,0
DA:48,0
DA:51,1
DA:60,1
DA:61,1
DA:62,1
DA:63,1
DA:64,1
DA:68,1
DA:71,1
LF:33
LH:31
BRDA:3,1,0,2
BRDA:3,1,1,2
BRDA:3,2,0,2
BRDA:3,2,1,0
BRDA:3,3,0,1
BRDA:3,3,1,0
BRDA:3,4,0,0
BRDA:3,4,1,1
BRDA:5,5,0,0
BRDA:5,5,1,1
BRDA:35,6,0,1
BRDA:35,6,1,0
BRF:12
BRH:7
end_of_record
TN:
SF:/Users/philkunz/gitlab/pushrocks/smartbrowser/dist/smartbrowser.plugins.js
FNF:0
FNH:0
DA:3,1
DA:4,1
DA:5,1
LF:3
LH:3
BRF:0
BRH:0
end_of_record

7
dist/index.d.ts vendored
View File

@ -1,5 +1,4 @@
/// <reference types="browser-sync" /> /// <reference types="browser-sync" />
/// <reference types="q" />
import * as plugins from './smartbrowser.plugins'; import * as plugins from './smartbrowser.plugins';
/** /**
* the options interface of a Smartbrowser instance * the options interface of a Smartbrowser instance
@ -19,14 +18,14 @@ export declare class Smartbrowser {
bsInstance: plugins.browserSync.BrowserSyncInstance; bsInstance: plugins.browserSync.BrowserSyncInstance;
bsConfig: plugins.browserSync.Options; bsConfig: plugins.browserSync.Options;
bsStatus: bsStatus; bsStatus: bsStatus;
bsStarted: plugins.q.Promise<void>; bsStarted: Promise<void>;
constructor(optionsArg: ISmartbrowserOptions); constructor(optionsArg: ISmartbrowserOptions);
/** /**
* starts the server and returns the browserSync instance in a resolved Promise * starts the server and returns the browserSync instance in a resolved Promise
*/ */
start(): plugins.q.Promise<plugins.browserSync.BrowserSyncInstance>; start(): Promise<plugins.browserSync.BrowserSyncInstance>;
/** /**
* stops the smartbrowser instance * stops the smartbrowser instance
*/ */
stop(): plugins.q.Promise<void>; stop(): Promise<void>;
} }

9
dist/index.js vendored
View File

@ -1,4 +1,5 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartbrowser.plugins"); const plugins = require("./smartbrowser.plugins");
/** /**
* class smartbrowser controls a browser-sync instance for you * class smartbrowser controls a browser-sync instance for you
@ -17,10 +18,10 @@ class Smartbrowser {
* starts the server and returns the browserSync instance in a resolved Promise * starts the server and returns the browserSync instance in a resolved Promise
*/ */
start() { start() {
let done = plugins.q.defer(); let done = plugins.smartq.defer();
if (this.bsStatus === 'idle') { if (this.bsStatus === 'idle') {
this.bsStatus = 'starting'; this.bsStatus = 'starting';
let localDone = plugins.q.defer(); let localDone = plugins.smartq.defer();
this.bsStarted = localDone.promise; this.bsStarted = localDone.promise;
this.bsInstance.init(this.bsConfig, () => { this.bsInstance.init(this.bsConfig, () => {
this.bsStatus = 'running'; this.bsStatus = 'running';
@ -37,7 +38,7 @@ class Smartbrowser {
* stops the smartbrowser instance * stops the smartbrowser instance
*/ */
stop() { stop() {
let done = plugins.q.defer(); let done = plugins.smartq.defer();
this.bsInstance.exit(); this.bsInstance.exit();
this.bsStatus = 'idle'; this.bsStatus = 'idle';
done.resolve(); done.resolve();
@ -45,4 +46,4 @@ class Smartbrowser {
} }
} }
exports.Smartbrowser = Smartbrowser; exports.Smartbrowser = Smartbrowser;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsa0RBQWlEO0FBZ0JqRDs7R0FFRztBQUNIO0lBT0ksWUFBWSxVQUFnQztRQU41QyxlQUFVLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLEVBQUUsQ0FBQTtRQUN6QyxhQUFRLEdBQWdDO1lBQ3BDLE1BQU0sRUFBRSxFQUFFO1NBQ2IsQ0FBQTtRQUNELGFBQVEsR0FBYSxNQUFNLENBQUE7UUFHdkIsSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsT0FBTyxHQUFHLFVBQVUsQ0FBQyxPQUFPLENBQUE7UUFDakQsSUFBSSxDQUFDLFFBQVEsQ0FBQyxLQUFLLEdBQUcsVUFBVSxDQUFDLFVBQVUsQ0FBQTtJQUMvQyxDQUFDO0lBRUQ7O09BRUc7SUFDSCxLQUFL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dBQUcsU0FBUyxDQUFDLE9BQU8sQ0FBQTtZQUNsQyxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsUUFBUSxFQUFFO2dCQUNsQyxJQUFJLENBQUMsUUFBUSxHQUFHLFNBQVMsQ0FBQTtnQkFDekIsU0FBUyxDQUFDLE9BQU8sRUFBRSxDQUFBO2dCQUNuQixJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsQ0FBQTtZQUMvQixDQUFDLENBQUMsQ0FBQTtRQUNKLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNOLElBQUksQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLFFBQVEsSUFBSSxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLENBQUEsQ0FBQyxDQUFDLENBQUMsQ0FBQTtRQUM5RCxDQUFDO1FBQ0QsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7SUFDckIsQ0FBQztJQUVEOztPQUVHO0lBQ0gsSUFBSTtRQUNGLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsS0FBSyxFQUFRLENBQUE7UUFDdkMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLEVBQUUsQ0FBQTtRQUN0QixJQUFJLENBQUMsUUFBUSxHQUFHLE1BQU0sQ0FBQTtRQUN0QixJQUFJLENBQUMsT0FBTyxFQUFFLENBQUE7UUFDZCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUNyQixDQUFDO0NBQ0Y7QUExQ0Qsb0NBMENDIn0=

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 q = require('q'); export import smartq = require('smartq');

View File

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

View File

@ -18,16 +18,13 @@
}, },
"homepage": "https://gitlab.com/pushrocks/smartbrowser#README", "homepage": "https://gitlab.com/pushrocks/smartbrowser#README",
"dependencies": { "dependencies": {
"@types/browser-sync": "0.0.32", "@types/browser-sync": "0.0.34",
"@types/q": "0.0.30", "browser-sync": "^2.18.8",
"browser-sync": "^2.16.0", "smartq": "^1.1.1",
"q": "^1.4.1",
"typings-global": "^1.0.14" "typings-global": "^1.0.14"
}, },
"devDependencies": { "devDependencies": {
"@types/should": "^8.1.29", "smartdelay": "^1.0.1",
"npmts-g": "^5.2.8", "tapbundle": "^1.0.5"
"should": "^11.1.0",
"typings-test": "^1.0.3"
} }
} }

1
test/test.d.ts vendored
View File

@ -1 +0,0 @@
import 'typings-test';

View File

@ -1,34 +1,29 @@
import 'typings-test' import { tap, expect } from 'tapbundle'
import * as should from 'should' 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
describe('smartbrowser', () => {
it('should instanstiate a new browser ', function () { tap.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/' ]
}) })
should(testSmartBrowser).be.instanceof(smartbrowser.Smartbrowser) return expect(testSmartBrowser).to.be.instanceof(smartbrowser.Smartbrowser)
}) }).catch(tap.threw)
it('should start the browser ', function (done) {
testSmartBrowser.start().then((bsInstance) => { tap.test('should start the browser ', async () => {
done() return await expect(testSmartBrowser.start()).to.eventually.be.fulfilled
}).catch((err) => { console.log(err) }) }).catch(tap.threw)
})
it('should stop the browser ', function (done) { tap.test('should stop the browser ', async () => {
this.timeout(10000) return await smartdelay.delayFor(2000).then(() => {
setTimeout(() => { return expect(testSmartBrowser.stop()).to.eventually.be.fulfilled
testSmartBrowser.stop().then(() => { })
done() })
}).catch((err) => { console.log(err) }) tap.test('should exit correctly', async () => {
}, 2000) smartdelay.delayFor(2000).then(() => {
}) process.exit(0)
it('should exit correctly',function(){ })
setTimeout(() => {
process.exit(0)
},2000)
})
}) })

View File

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

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 q = require('q') export import smartq = require('smartq')

View File

@ -1,3 +1,3 @@
{ {
"extends": "tslint-config-standard" "extends": "tslint-config-standard"
} }

2818
yarn.lock Normal file

File diff suppressed because it is too large Load Diff