Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
246037aaae | |||
3fc91bc0c1 | |||
6c3991f6bc | |||
cfcba1aa01 | |||
b8a7f02b97 | |||
d6a7fd6c8c | |||
6e079e38c3 | |||
38d1aa5477 | |||
6f8ce94ae2 | |||
f3a78ba089 | |||
43bc078ace |
23
.gitignore
vendored
23
.gitignore
vendored
@ -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
|
119
.gitlab-ci.yml
119
.gitlab-ci.yml
@ -1,34 +1,125 @@
|
|||||||
image: hosttoday/ht-docker-node:npmts
|
# gitzone standard
|
||||||
|
image: hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci_cache/
|
||||||
|
key: "$CI_BUILD_STAGE"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
|
- metadata
|
||||||
|
|
||||||
testLEGACY:
|
# ====================
|
||||||
stage: test
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci git mirror
|
||||||
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/
|
||||||
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/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
environment: npm_registry
|
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci node install stable
|
||||||
|
- npmci npm publish
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- 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:
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npmci trigger
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
pages:
|
||||||
|
image: hosttoday/ht-docker-node:npmci
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command tsdoc
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
artifacts:
|
||||||
- docker
|
expire_in: 1 week
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
43
README.md
43
README.md
@ -1,20 +1,35 @@
|
|||||||
# smartbrowser
|
# @pushrocks/smartbrowser
|
||||||
easy class API for serving stacks during development with `browser-sync`.
|
puppeteer wrapper for easy tasks
|
||||||
|
|
||||||
## Availabililty
|
## Availabililty and Links
|
||||||
[](https://www.npmjs.com/package/smartbrowser)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartbrowser)
|
||||||
[](https://gitlab.com/pushrocks/smartbrowser)
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartbrowser)
|
||||||
[](https://github.com/pushrocks/smartbrowser)
|
* [github.com (source mirror)](https://github.com/pushrocks/smartbrowser)
|
||||||
[](https://pushrocks.gitlab.io/smartbrowser/)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartbrowser/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://gitlab.com/pushrocks/smartbrowser/commits/master)
|
[](https://gitlab.com/pushrocks/smartbrowser/commits/master)
|
||||||
[](https://gitlab.com/pushrocks/smartbrowser/commits/master)
|
[](https://gitlab.com/pushrocks/smartbrowser/commits/master)
|
||||||
[](https://david-dm.org/pushrocks/smartbrowser)
|
[](https://www.npmjs.com/package/@pushrocks/smartbrowser)
|
||||||
[](https://www.bithound.io/github/pushrocks/smartbrowser/master/dependencies/npm)
|
[](https://snyk.io/test/npm/@pushrocks/smartbrowser)
|
||||||
[](https://www.bithound.io/github/pushrocks/smartbrowser)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
[](https://prettier.io/)
|
||||||
[](http://standardjs.com/)
|
|
||||||
|
|
||||||
[](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)
|
||||||
|
|
||||||
|
[](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)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
||||||
|
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
|
|
32
dist/index.d.ts
vendored
32
dist/index.d.ts
vendored
@ -1,32 +0,0 @@
|
|||||||
/// <reference types="browser-sync" />
|
|
||||||
/// <reference types="q" />
|
|
||||||
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: plugins.q.Promise<void>;
|
|
||||||
constructor(optionsArg: ISmartbrowserOptions);
|
|
||||||
/**
|
|
||||||
* starts the server and returns the browserSync instance in a resolved Promise
|
|
||||||
*/
|
|
||||||
start(): plugins.q.Promise<plugins.browserSync.BrowserSyncInstance>;
|
|
||||||
/**
|
|
||||||
* stops the smartbrowser instance
|
|
||||||
*/
|
|
||||||
stop(): plugins.q.Promise<void>;
|
|
||||||
}
|
|
48
dist/index.js
vendored
48
dist/index.js
vendored
@ -1,48 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
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() {
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
if (this.bsStatus === 'idle') {
|
|
||||||
this.bsStatus = 'starting';
|
|
||||||
let localDone = plugins.q.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 done.promise;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* stops the smartbrowser instance
|
|
||||||
*/
|
|
||||||
stop() {
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
this.bsInstance.exit();
|
|
||||||
this.bsStatus = 'idle';
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.Smartbrowser = Smartbrowser;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsa0RBQWlEO0FBZ0JqRDs7R0FFRztBQUNIO0lBT0ksWUFBWSxVQUFnQztRQU41QyxlQUFVLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLEVBQUUsQ0FBQTtRQUN6QyxhQUFRLEdBQWdDO1lBQ3BDLE1BQU0sRUFBRSxFQUFFO1NBQ2IsQ0FBQTtRQUNELGFBQVEsR0FBYSxNQUFNLENBQUE7UUFHdkIsSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsT0FBTyxHQUFHLFVBQVUsQ0FBQyxPQUFPLENBQUE7UUFDakQsSUFBSSxDQUFDLFFBQVEsQ0FBQyxLQUFLLEdBQUcsVUFBVSxDQUFDLFVBQVUsQ0FBQTtJQUMvQyxDQUFDO0lBRUQ7O09BRUc7SUFDSCxLQUFLO1FBQ0QsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQTJDLENBQUE7UUFDckUsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLFFBQVEsS0FBSyxNQUFNLENBQUMsQ0FBQyxDQUFDO1lBQzNCLElBQUksQ0FBQyxRQUFRLEdBQUcsVUFBVSxDQUFBO1lBQzFCLElBQUksU0FBUyxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFRLENBQUE7WUFDdkMsSUFBSSxDQUFDLFNBQVMsR0FBRyxTQUFTLENBQUMsT0FBTyxDQUFBO1lBQ2xDLElBQUksQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxRQUFRLEVBQUU7Z0JBQ2hDLElBQUksQ0FBQyxRQUFRLEdBQUcsU0FBUyxDQUFBO2dCQUN6QixTQUFTLENBQUMsT0FBTyxFQUFFLENBQUE7Z0JBQ25CLElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxDQUFBO1lBQ2pDLENBQUMsQ0FBQyxDQUFBO1FBQ04sQ0FBQztRQUFDLElBQUksQ0FBQyxDQUFDO1lBQ0osSUFBSSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUUsUUFBUSxJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsQ0FBQSxDQUFDLENBQUMsQ0FBQyxDQUFBO1FBQ2pFLENBQUM7UUFDRCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUN2QixDQUFDO0lBRUQ7O09BRUc7SUFDSCxJQUFJO1FBQ0EsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQVEsQ0FBQTtRQUNsQyxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksRUFBRSxDQUFBO1FBQ3RCLElBQUksQ0FBQyxRQUFRLEdBQUcsTUFBTSxDQUFBO1FBQ3RCLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQTtRQUNkLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0lBQ3ZCLENBQUM7Q0FDSjtBQTFDRCxvQ0EwQ0MifQ==
|
|
3
dist/smartbrowser.plugins.d.ts
vendored
3
dist/smartbrowser.plugins.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
import 'typings-global';
|
|
||||||
export import browserSync = require('browser-sync');
|
|
||||||
export import q = require('q');
|
|
5
dist/smartbrowser.plugins.js
vendored
5
dist/smartbrowser.plugins.js
vendored
@ -1,5 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
||||||
exports.browserSync = require("browser-sync");
|
|
||||||
exports.q = require("q");
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRicm93c2VyLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGJyb3dzZXIucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDhDQUFtRDtBQUNuRCx5QkFBOEIifQ==
|
|
17
npmextra.json
Normal file
17
npmextra.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"globalNpmTools": [
|
||||||
|
"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
1918
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
37
package.json
37
package.json
@ -1,11 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "smartbrowser",
|
"name": "@pushrocks/smartbrowser",
|
||||||
"version": "1.0.1",
|
"version": "1.0.7",
|
||||||
"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,16 +19,24 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartbrowser#README",
|
"homepage": "https://gitlab.com/pushrocks/smartbrowser#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/browser-sync": "0.0.32",
|
"puppeteer": "^1.17.0"
|
||||||
"@types/q": "0.0.30",
|
|
||||||
"browser-sync": "^2.16.0",
|
|
||||||
"q": "^1.4.1",
|
|
||||||
"typings-global": "^1.0.14"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/should": "^8.1.29",
|
"@gitzone/tsbuild": "^2.1.11",
|
||||||
"npmts-g": "^5.2.8",
|
"@gitzone/tstest": "^1.0.24",
|
||||||
"should": "^11.1.0",
|
"@pushrocks/tapbundle": "^3.0.9",
|
||||||
"typings-test": "^1.0.3"
|
"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"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
import 'typings-test';
|
|
60
test/test.ts
60
test/test.ts
@ -1,34 +1,32 @@
|
|||||||
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
|
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);
|
||||||
|
|
||||||
describe('smartbrowser', () => {
|
tap
|
||||||
it('should instanstiate a new browser ', function () {
|
.test('should start the browser ', async () => {
|
||||||
testSmartBrowser = new smartbrowser.Smartbrowser({
|
return await expect(testSmartBrowser.start()).to.eventually.be.fulfilled;
|
||||||
webroot: './test/assets/',
|
})
|
||||||
watchFiles: ['./test/assets/']
|
.catch(tap.threw);
|
||||||
})
|
|
||||||
should(testSmartBrowser).be.instanceof(smartbrowser.Smartbrowser)
|
tap.test('should stop the browser ', async () => {
|
||||||
})
|
return await smartdelay.delayFor(2000).then(() => {
|
||||||
it('should start the browser ', function (done) {
|
return expect(testSmartBrowser.stop()).to.eventually.be.fulfilled;
|
||||||
testSmartBrowser.start().then((bsInstance) => {
|
});
|
||||||
done()
|
});
|
||||||
}).catch((err) => { console.log(err) })
|
tap.test('should exit correctly', async () => {
|
||||||
})
|
smartdelay.delayFor(2000).then(() => {
|
||||||
it('should stop the browser ', function (done) {
|
process.exit(0);
|
||||||
this.timeout(10000)
|
});
|
||||||
setTimeout(() => {
|
});
|
||||||
testSmartBrowser.stop().then(() => {
|
|
||||||
done()
|
|
||||||
}).catch((err) => { console.log(err) })
|
|
||||||
}, 2000)
|
|
||||||
})
|
|
||||||
it('should exit correctly',function(){
|
|
||||||
setTimeout(() => {
|
|
||||||
process.exit(0)
|
|
||||||
},2000)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
63
ts/index.ts
63
ts/index.ts
@ -1,62 +1,3 @@
|
|||||||
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: plugins.q.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
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -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');
|
||||||
|
18
tslint.json
18
tslint.json
@ -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"
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user