11 Commits

Author SHA1 Message Date
246037aaae 1.0.7 2019-05-28 23:28:27 +02:00
3fc91bc0c1 fix(core): update 2019-05-28 23:28:26 +02:00
6c3991f6bc 1.0.6 2019-05-28 23:27:56 +02:00
cfcba1aa01 fix(core): update 2019-05-28 23:27:55 +02:00
b8a7f02b97 1.0.5 2017-04-09 16:05:27 +02:00
d6a7fd6c8c add .reload() 2017-04-09 16:05:24 +02:00
6e079e38c3 1.0.4 2017-04-09 13:05:13 +02:00
38d1aa5477 add npmextra.json 2017-04-09 13:05:10 +02:00
6f8ce94ae2 1.0.3 2017-04-09 12:45:32 +02:00
f3a78ba089 1.0.2 2017-04-09 12:35:58 +02:00
43bc078ace update to latest standards 2017-04-09 12:35:53 +02:00
17 changed files with 2163 additions and 321 deletions

23
.gitignore vendored
View File

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

View File

@ -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:
- security
- test
- release
- metadata
testLEGACY:
stage: test
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci test legacy
- npmci git mirror
tags:
- 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:
stage: test
script:
- npmci test lts
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
stage: test
script:
- npmci test stable
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
release:
stage: release
environment: npm_registry
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:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

View File

@ -1,20 +1,35 @@
# smartbrowser
easy class API for serving stacks during development with `browser-sync`.
# @pushrocks/smartbrowser
puppeteer wrapper for easy tasks
## 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/)
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartbrowser)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartbrowser)
* [github.com (source mirror)](https://github.com/pushrocks/smartbrowser)
* [docs (typedoc)](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)
[![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)
[![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/)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartbrowser.svg)](https://www.npmjs.com/package/@pushrocks/smartbrowser)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartbrowser/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartbrowser)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
[![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)
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)

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

32
dist/index.d.ts vendored
View File

@ -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
View File

@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJ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yxDQUFBO1lBQ2pDLENBQUMsQ0FBQyxDQUFBO1FBQ04sQ0FBQztRQUFDLElBQUksQ0FBQyxDQUFDO1lBQ0osSUFBSSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUUsUUFBUSxJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsQ0FBQSxDQUFDLENBQUMsQ0FBQyxDQUFBO1FBQ2pFLENBQUM7UUFDRCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUN2QixDQUFDO0lBRUQ7O09BRUc7SUFDSCxJQUFJO1FBQ0EsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQVEsQ0FBQTtRQUNsQyxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksRUFBRSxDQUFBO1FBQ3RCLElBQUksQ0FBQyxRQUFRLEdBQUcsTUFBTSxDQUFBO1FBQ3RCLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQTtRQUNkLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0lBQ3ZCLENBQUM7Q0FDSjtBQTFDRCxvQ0EwQ0MifQ==

View File

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

View File

@ -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
View 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

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,12 @@
{
"name": "smartbrowser",
"version": "1.0.1",
"description": "wraps browser-sync",
"name": "@pushrocks/smartbrowser",
"version": "1.0.7",
"description": "simplified puppeteer",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"test": "(npmts)"
"test": "(npmts)",
"build": "echo \"Not needed for now\""
},
"repository": {
"type": "git",
@ -18,16 +19,24 @@
},
"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",
"typings-global": "^1.0.14"
"puppeteer": "^1.17.0"
},
"devDependencies": {
"@types/should": "^8.1.29",
"npmts-g": "^5.2.8",
"should": "^11.1.0",
"typings-test": "^1.0.3"
}
"@gitzone/tsbuild": "^2.1.11",
"@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"
]
}

1
test/test.d.ts vendored
View File

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

View File

@ -1,34 +1,32 @@
import 'typings-test'
import * as should from 'should'
import { tap, expect } from 'tapbundle';
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({
webroot: './test/assets/',
watchFiles: ['./test/assets/']
});
return expect(testSmartBrowser).to.be.instanceof(smartbrowser.Smartbrowser);
})
should(testSmartBrowser).be.instanceof(smartbrowser.Smartbrowser)
.catch(tap.threw);
tap
.test('should start the browser ', async () => {
return await expect(testSmartBrowser.start()).to.eventually.be.fulfilled;
})
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)
})
})
.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);
});
});

View File

@ -1,62 +1,3 @@
import * as plugins from './smartbrowser.plugins'
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 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
}
}
export class SmartBrowser {}

View File

@ -1,3 +1,3 @@
import 'typings-global'
export import browserSync = require('browser-sync')
export import q = require('q')
import 'typings-global';
export import browserSync = require('browser-sync');
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"
}