update to latest standards
This commit is contained in:
parent
c9fd889dd3
commit
43bc078ace
@ -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:
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
@ -21,14 +33,39 @@ testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
environment: npm_registry
|
||||
script:
|
||||
- npmci publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- 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
|
||||
|
25
README.md
25
README.md
@ -1,15 +1,16 @@
|
||||
# smartbrowser
|
||||
easy class API for serving stacks during development with `browser-sync`.
|
||||
wraps browser-sync
|
||||
|
||||
## Availabililty
|
||||
[![npm](https://push.rocks/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://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartbrowser)
|
||||
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartbrowser/)
|
||||
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartbrowser)
|
||||
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartbrowser)
|
||||
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartbrowser)
|
||||
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartbrowser/)
|
||||
|
||||
## Status for 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)
|
||||
[![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)
|
||||
[![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)
|
||||
[![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)
|
||||
@ -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/)
|
||||
[![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
@ -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
7
dist/index.d.ts
vendored
@ -1,5 +1,4 @@
|
||||
/// <reference types="browser-sync" />
|
||||
/// <reference types="q" />
|
||||
import * as plugins from './smartbrowser.plugins';
|
||||
/**
|
||||
* the options interface of a Smartbrowser instance
|
||||
@ -19,14 +18,14 @@ export declare class Smartbrowser {
|
||||
bsInstance: plugins.browserSync.BrowserSyncInstance;
|
||||
bsConfig: plugins.browserSync.Options;
|
||||
bsStatus: bsStatus;
|
||||
bsStarted: plugins.q.Promise<void>;
|
||||
bsStarted: Promise<void>;
|
||||
constructor(optionsArg: ISmartbrowserOptions);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
stop(): plugins.q.Promise<void>;
|
||||
stop(): Promise<void>;
|
||||
}
|
||||
|
9
dist/index.js
vendored
9
dist/index.js
vendored
@ -1,4 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const plugins = require("./smartbrowser.plugins");
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
start() {
|
||||
let done = plugins.q.defer();
|
||||
let done = plugins.smartq.defer();
|
||||
if (this.bsStatus === 'idle') {
|
||||
this.bsStatus = 'starting';
|
||||
let localDone = plugins.q.defer();
|
||||
let localDone = plugins.smartq.defer();
|
||||
this.bsStarted = localDone.promise;
|
||||
this.bsInstance.init(this.bsConfig, () => {
|
||||
this.bsStatus = 'running';
|
||||
@ -37,7 +38,7 @@ class Smartbrowser {
|
||||
* stops the smartbrowser instance
|
||||
*/
|
||||
stop() {
|
||||
let done = plugins.q.defer();
|
||||
let done = plugins.smartq.defer();
|
||||
this.bsInstance.exit();
|
||||
this.bsStatus = 'idle';
|
||||
done.resolve();
|
||||
@ -45,4 +46,4 @@ class Smartbrowser {
|
||||
}
|
||||
}
|
||||
exports.Smartbrowser = Smartbrowser;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQ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FHLE9BQU8sQ0FBQyxNQUFNLENBQUMsS0FBSyxFQUFRLENBQUE7UUFDdkMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLEVBQUUsQ0FBQTtRQUN0QixJQUFJLENBQUMsUUFBUSxHQUFHLE1BQU0sQ0FBQTtRQUN0QixJQUFJLENBQUMsT0FBTyxFQUFFLENBQUE7UUFDZCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUNyQixDQUFDO0NBQ0Y7QUExQ0Qsb0NBMENDIn0=
|
2
dist/smartbrowser.plugins.d.ts
vendored
2
dist/smartbrowser.plugins.d.ts
vendored
@ -1,3 +1,3 @@
|
||||
import 'typings-global';
|
||||
export import browserSync = require('browser-sync');
|
||||
export import q = require('q');
|
||||
export import smartq = require('smartq');
|
||||
|
5
dist/smartbrowser.plugins.js
vendored
5
dist/smartbrowser.plugins.js
vendored
@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("typings-global");
|
||||
exports.browserSync = require("browser-sync");
|
||||
exports.q = require("q");
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRicm93c2VyLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGJyb3dzZXIucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDhDQUFtRDtBQUNuRCx5QkFBOEIifQ==
|
||||
exports.smartq = require("smartq");
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRicm93c2VyLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGJyb3dzZXIucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2Qiw4Q0FBbUQ7QUFDbkQsbUNBQXdDIn0=
|
13
package.json
13
package.json
@ -18,16 +18,13 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/smartbrowser#README",
|
||||
"dependencies": {
|
||||
"@types/browser-sync": "0.0.32",
|
||||
"@types/q": "0.0.30",
|
||||
"browser-sync": "^2.16.0",
|
||||
"q": "^1.4.1",
|
||||
"@types/browser-sync": "0.0.34",
|
||||
"browser-sync": "^2.18.8",
|
||||
"smartq": "^1.1.1",
|
||||
"typings-global": "^1.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/should": "^8.1.29",
|
||||
"npmts-g": "^5.2.8",
|
||||
"should": "^11.1.0",
|
||||
"typings-test": "^1.0.3"
|
||||
"smartdelay": "^1.0.1",
|
||||
"tapbundle": "^1.0.5"
|
||||
}
|
||||
}
|
||||
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
||||
import 'typings-test';
|
53
test/test.ts
53
test/test.ts
@ -1,34 +1,29 @@
|
||||
import 'typings-test'
|
||||
import * as should from 'should'
|
||||
import { tap, expect } from 'tapbundle'
|
||||
import * as smartdelay from 'smartdelay'
|
||||
|
||||
import * as smartbrowser from '../dist/index'
|
||||
|
||||
let testSmartBrowser: smartbrowser.Smartbrowser
|
||||
|
||||
describe('smartbrowser', () => {
|
||||
it('should instanstiate a new browser ', function () {
|
||||
testSmartBrowser = new smartbrowser.Smartbrowser({
|
||||
webroot: './test/assets/',
|
||||
watchFiles: ['./test/assets/']
|
||||
})
|
||||
should(testSmartBrowser).be.instanceof(smartbrowser.Smartbrowser)
|
||||
})
|
||||
it('should start the browser ', function (done) {
|
||||
testSmartBrowser.start().then((bsInstance) => {
|
||||
done()
|
||||
}).catch((err) => { console.log(err) })
|
||||
})
|
||||
it('should stop the browser ', function (done) {
|
||||
this.timeout(10000)
|
||||
setTimeout(() => {
|
||||
testSmartBrowser.stop().then(() => {
|
||||
done()
|
||||
}).catch((err) => { console.log(err) })
|
||||
}, 2000)
|
||||
})
|
||||
it('should exit correctly',function(){
|
||||
setTimeout(() => {
|
||||
process.exit(0)
|
||||
},2000)
|
||||
})
|
||||
|
||||
tap.test('should instanstiate a new browser ', async () => {
|
||||
testSmartBrowser = new smartbrowser.Smartbrowser({
|
||||
webroot: './test/assets/',
|
||||
watchFiles: [ './test/assets/' ]
|
||||
})
|
||||
return expect(testSmartBrowser).to.be.instanceof(smartbrowser.Smartbrowser)
|
||||
}).catch(tap.threw)
|
||||
|
||||
tap.test('should start the browser ', async () => {
|
||||
return await expect(testSmartBrowser.start()).to.eventually.be.fulfilled
|
||||
}).catch(tap.threw)
|
||||
|
||||
tap.test('should stop the browser ', async () => {
|
||||
return await smartdelay.delayFor(2000).then(() => {
|
||||
return expect(testSmartBrowser.stop()).to.eventually.be.fulfilled
|
||||
})
|
||||
})
|
||||
tap.test('should exit correctly', async () => {
|
||||
smartdelay.delayFor(2000).then(() => {
|
||||
process.exit(0)
|
||||
})
|
||||
})
|
||||
|
80
ts/index.ts
80
ts/index.ts
@ -4,8 +4,8 @@ import * as plugins from './smartbrowser.plugins'
|
||||
* the options interface of a Smartbrowser instance
|
||||
*/
|
||||
export interface ISmartbrowserOptions {
|
||||
webroot: string
|
||||
watchFiles: string[]
|
||||
webroot: string
|
||||
watchFiles: string[]
|
||||
|
||||
}
|
||||
|
||||
@ -18,45 +18,45 @@ 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: plugins.q.Promise<void>
|
||||
constructor(optionsArg: ISmartbrowserOptions) {
|
||||
this.bsConfig.server.baseDir = optionsArg.webroot
|
||||
this.bsConfig.files = optionsArg.watchFiles
|
||||
}
|
||||
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
|
||||
*/
|
||||
start(): plugins.q.Promise<plugins.browserSync.BrowserSyncInstance> {
|
||||
let done = plugins.q.defer<plugins.browserSync.BrowserSyncInstance>()
|
||||
if (this.bsStatus === 'idle') {
|
||||
this.bsStatus = 'starting'
|
||||
let localDone = plugins.q.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 done.promise
|
||||
/**
|
||||
* starts the server and returns the browserSync instance in a resolved Promise
|
||||
*/
|
||||
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 done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* stops the smartbrowser instance
|
||||
*/
|
||||
stop(): plugins.q.Promise<void> {
|
||||
let done = plugins.q.defer<void>()
|
||||
this.bsInstance.exit()
|
||||
this.bsStatus = 'idle'
|
||||
done.resolve()
|
||||
return done.promise
|
||||
}
|
||||
/**
|
||||
* stops the smartbrowser instance
|
||||
*/
|
||||
stop (): Promise<void> {
|
||||
let done = plugins.smartq.defer<void>()
|
||||
this.bsInstance.exit()
|
||||
this.bsStatus = 'idle'
|
||||
done.resolve()
|
||||
return done.promise
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
import 'typings-global'
|
||||
export import browserSync = require('browser-sync')
|
||||
export import q = require('q')
|
||||
export import smartq = require('smartq')
|
||||
|
Loading…
Reference in New Issue
Block a user