Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
7d377e31c2 | |||
fcb12d5734 | |||
febf6c1911 | |||
457ac52a14 | |||
495a3ffafd | |||
ffd1274f21 | |||
8e4ad6159a | |||
c5a2383fd3 | |||
2c25cd0655 | |||
370caae226 | |||
75c3979120 | |||
b5d792d58c | |||
05b80b618b | |||
511b7ee143 | |||
08d37dc037 | |||
2b5056085c | |||
8f31088ab5 | |||
6e99af15f9 | |||
914615fa4d | |||
70c6ffcbd3 | |||
b3023d61f3 |
@ -15,7 +15,9 @@ stages:
|
|||||||
testLEGACY:
|
testLEGACY:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
@ -24,7 +26,9 @@ testLEGACY:
|
|||||||
testLTS:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
@ -32,7 +36,9 @@ testLTS:
|
|||||||
testSTABLE:
|
testSTABLE:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test stable
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
@ -40,7 +46,8 @@ testSTABLE:
|
|||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci npm prepare
|
||||||
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
27
README.md
27
README.md
@ -22,23 +22,36 @@ Google Analytics everywhere
|
|||||||
Use TypeScript for best in class instellisense.
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
### Why does this package exist?
|
### Why does this package exist?
|
||||||
Tracking users in webapps is common. We use Google Analytics to gain insight in who is using what
|
Tracking users in webapps is common, often to gain insight in who is using what and where to spend dev resources for best efficiency.
|
||||||
and where to spend resources for best efficiency.
|
|
||||||
|
|
||||||
Doing the same stuff in apps can be a bit of a hassle.
|
Doing the same stuff in apps can be a bit of a hassle.
|
||||||
Unnecessary dependencies used by many existing analytics tools make the whole app slow
|
Unnecessary dependencies used by many existing analytics tools make the whole app slow
|
||||||
just to gain a little usage info.
|
just to gain a little usage info.
|
||||||
Say hello to smartanalytics.
|
|
||||||
It features a very slim dependency tree using the native node request module to send posts to Google Analytics.
|
**Say hello to smartanalytics. :)**
|
||||||
|
It features a very slim dependency tree using the native node request module to send posts to a tracking API of your choice.
|
||||||
|
|
||||||
### How do I use this package?
|
### How do I use this package?
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import {AnalyticsAccount} from 'smartanalytics'
|
import { Analytics } from 'smartanalytics'
|
||||||
let myAnalyticsAccount = new AnalyticsAccount('My App Name', 'UA-XXXXXX-Y')
|
let myAnalytics = new plugins.smartanalytics.Analytics({
|
||||||
myAnalyticsAccount.sendEvent('npmtool', 'install', 'somelabel')
|
apiEndPoint: 'https://somepubapi.endpoint.com',
|
||||||
|
projectId: 'gitzone',
|
||||||
|
appName: 'npmts'
|
||||||
|
})
|
||||||
|
|
||||||
|
myAnalytics.recordEvent('someEvent', {
|
||||||
|
myKey1: 'myValue1',
|
||||||
|
myKey2: 'myValue2',
|
||||||
|
myDataKey3: 3
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
|
12
dist/smartanalytics.classes.analytics.d.ts
vendored
12
dist/smartanalytics.classes.analytics.d.ts
vendored
@ -1,13 +1,13 @@
|
|||||||
export declare class Analytics {
|
export declare class Analytics {
|
||||||
project: string;
|
projectId: string;
|
||||||
appName: string;
|
appName: string;
|
||||||
apiEndPoint: string;
|
apiEndPoint: string;
|
||||||
secretKey: string;
|
secretKey: string;
|
||||||
constructor(optionsArg: {
|
constructor(optionsArg: {
|
||||||
projectArg: string;
|
projectId: string;
|
||||||
appNameArg: string;
|
appName: string;
|
||||||
apiEndPointArg: string;
|
apiEndPoint: string;
|
||||||
secretKeyArg?: string;
|
secretKey?: string;
|
||||||
});
|
});
|
||||||
recordEvent(identifierArg: string, analyticsDataArg: any): Promise<void>;
|
recordEvent(eventIdArg: string, analyticsDataArg: any): Promise<void>;
|
||||||
}
|
}
|
||||||
|
19
dist/smartanalytics.classes.analytics.js
vendored
19
dist/smartanalytics.classes.analytics.js
vendored
@ -12,22 +12,21 @@ const plugins = require("./smartanalytics.plugins");
|
|||||||
class Analytics {
|
class Analytics {
|
||||||
constructor(optionsArg) {
|
constructor(optionsArg) {
|
||||||
this.secretKey = '';
|
this.secretKey = '';
|
||||||
this.project = optionsArg.projectArg;
|
this.projectId = optionsArg.projectId;
|
||||||
this.appName = optionsArg.appNameArg;
|
this.appName = optionsArg.appName;
|
||||||
this.apiEndPoint = optionsArg.apiEndPointArg;
|
this.apiEndPoint = optionsArg.apiEndPoint;
|
||||||
if (optionsArg.secretKeyArg) {
|
if (optionsArg.secretKey) {
|
||||||
this.secretKey = optionsArg.secretKeyArg;
|
this.secretKey = optionsArg.secretKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recordEvent(identifierArg, analyticsDataArg) {
|
recordEvent(eventIdArg, analyticsDataArg) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let dataToSend = {
|
let dataToSend = {
|
||||||
project: this.project,
|
projectId: this.projectId,
|
||||||
appName: this.appName,
|
appName: this.appName,
|
||||||
identifier: identifierArg,
|
eventId: eventIdArg,
|
||||||
analyticsData: analyticsDataArg
|
analyticsData: analyticsDataArg
|
||||||
};
|
};
|
||||||
console.log(dataToSend);
|
|
||||||
yield plugins.smartrequest.post(this.apiEndPoint, {
|
yield plugins.smartrequest.post(this.apiEndPoint, {
|
||||||
headers: {
|
headers: {
|
||||||
'authenticate': this.secretKey,
|
'authenticate': this.secretKey,
|
||||||
@ -41,4 +40,4 @@ class Analytics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.Analytics = Analytics;
|
exports.Analytics = Analytics;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhbmFseXRpY3MuY2xhc3Nlcy5hbmFseXRpY3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFuYWx5dGljcy5jbGFzc2VzLmFuYWx5dGljcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsb0RBQW1EO0FBRW5EO0lBS0UsWUFBYSxVQUtaO1FBTkQsY0FBUyxHQUFXLEVBQUUsQ0FBQTtRQU9wQixJQUFJLENBQUMsT0FBTyxHQUFHLFVBQVUsQ0FBQyxVQUFVLENBQUE7UUFDcEMsSUFBSSxDQUFDLE9BQU8sR0FBRyxVQUFVLENBQUMsVUFBVSxDQUFBO1FBQ3BDLElBQUksQ0FBQyxXQUFXLEdBQUcsVUFBVSxDQUFDLGNBQWMsQ0FBQTtRQUM1QyxFQUFFLENBQUMsQ0FBQyxVQUF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file
@ -0,0 +1,59 @@
|
|||||||
|
# smartanalytics
|
||||||
|
Google Analytics everywhere
|
||||||
|
|
||||||
|
## Availabililty
|
||||||
|
[](https://www.npmjs.com/package/smartanalytics)
|
||||||
|
[](https://GitLab.com/pushrocks/smartanalytics)
|
||||||
|
[](https://github.com/pushrocks/smartanalytics)
|
||||||
|
[](https://pushrocks.gitlab.io/smartanalytics/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://GitLab.com/pushrocks/smartanalytics/commits/master)
|
||||||
|
[](https://GitLab.com/pushrocks/smartanalytics/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/smartanalytics)
|
||||||
|
[](https://david-dm.org/pushrocks/smartanalytics)
|
||||||
|
[](https://www.bithound.io/github/pushrocks/smartanalytics/master/dependencies/npm)
|
||||||
|
[](https://www.bithound.io/github/pushrocks/smartanalytics)
|
||||||
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
[](http://standardjs.com/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
|
### Why does this package exist?
|
||||||
|
Tracking users in webapps is common, often to gain insight in who is using what and where to spend dev resources for best efficiency.
|
||||||
|
|
||||||
|
Doing the same stuff in apps can be a bit of a hassle.
|
||||||
|
Unnecessary dependencies used by many existing analytics tools make the whole app slow
|
||||||
|
just to gain a little usage info.
|
||||||
|
|
||||||
|
**Say hello to smartanalytics. :)**
|
||||||
|
It features a very slim dependency tree using the native node request module to send posts to a tracking API of your choice.
|
||||||
|
|
||||||
|
### How do I use this package?
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import { Analytics } from 'smartanalytics'
|
||||||
|
let myAnalytics = new plugins.smartanalytics.Analytics({
|
||||||
|
apiEndPoint: 'https://somepubapi.endpoint.com',
|
||||||
|
projectId: 'gitzone',
|
||||||
|
appName: 'npmts'
|
||||||
|
})
|
||||||
|
|
||||||
|
myAnalytics.recordEvent('someEvent', {
|
||||||
|
myKey1: 'myValue1',
|
||||||
|
myKey2: 'myValue2',
|
||||||
|
myDataKey3: 3
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
|
||||||
|
[](https://push.rocks)
|
19
license
Normal file
19
license
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2018 Lossless GmbH (hello@lossless.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
@ -1,10 +1,8 @@
|
|||||||
{
|
{
|
||||||
"npmts": {
|
"npmts": {
|
||||||
"coverageTreshold": 40
|
|
||||||
},
|
},
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"globalNpmTools": [
|
"npmGlobalTools": [],
|
||||||
"npmts"
|
"npmAccessLevel": "public"
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
1046
package-lock.json
generated
Normal file
1046
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@ -1,20 +1,24 @@
|
|||||||
{
|
{
|
||||||
"name": "smartanalytics",
|
"name": "@pushrocks/smartanalytics",
|
||||||
"version": "2.0.1",
|
"version": "2.0.11",
|
||||||
"description": "Google Analytics everywhere",
|
"description": "Google Analytics everywhere",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "(tstest test/)"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"smartq": "^1.1.1",
|
"@pushrocks/smartpromise": "^2.0.5",
|
||||||
"smartrequest": "^1.0.4",
|
"@pushrocks/smartrequest": "^1.1.14"
|
||||||
"typings-global": "^1.0.14"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tapbundle": "^1.1.1"
|
"@gitzone/tsbuild": "^2.0.22",
|
||||||
|
"@gitzone/tstest": "^1.0.15",
|
||||||
|
"@pushrocks/tapbundle": "^3.0.7",
|
||||||
|
"@types/node": "^10.12.0",
|
||||||
|
"tslint": "^5.11.0",
|
||||||
|
"tslint-config-prettier": "^1.15.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
32
test/test.ts
32
test/test.ts
@ -1,27 +1,27 @@
|
|||||||
import { expect, tap } from 'tapbundle'
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
|
|
||||||
import * as smartanalytics from '../ts/index'
|
import * as smartanalytics from '../ts/index';
|
||||||
|
|
||||||
let testAnalytics: smartanalytics.Analytics
|
let testAnalytics: smartanalytics.Analytics;
|
||||||
|
|
||||||
tap.test('should create a valid AnalyticsAccount', async () => {
|
tap.test('should create a valid AnalyticsAccount', async () => {
|
||||||
testAnalytics = new smartanalytics.Analytics({
|
testAnalytics = new smartanalytics.Analytics({
|
||||||
projectArg: 'pushrocks',
|
projectId: 'sandbox',
|
||||||
appNameArg: 'smartanalytics',
|
appName: 'smartanalytics',
|
||||||
apiEndPointArg: 'https://pubapi-1.herokuapp.com/analytics'
|
apiEndPoint: 'https://pubapi.lossless.one/analytics'
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('should send a request to Google Analytics', async () => {
|
tap.test('should send a request to Lossless API endpoint', async () => {
|
||||||
let doit = async () => {
|
let doit = async () => {
|
||||||
await testAnalytics.recordEvent('sandbox', {
|
await testAnalytics.recordEvent('sandbox', {
|
||||||
someValue: 'someData'
|
trackingPurpose: 'test'
|
||||||
})
|
});
|
||||||
await testAnalytics.recordEvent('sandbox', {
|
await testAnalytics.recordEvent('sandbox', {
|
||||||
someValue: 'someData'
|
someValue: 'someData'
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
doit()
|
doit();
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.start()
|
tap.start();
|
||||||
|
@ -1 +1 @@
|
|||||||
export { Analytics } from './smartanalytics.classes.analytics'
|
export { Analytics } from './smartanalytics.classes.analytics';
|
||||||
|
@ -1,40 +1,41 @@
|
|||||||
import * as plugins from './smartanalytics.plugins'
|
import * as plugins from './smartanalytics.plugins';
|
||||||
|
|
||||||
export class Analytics {
|
export class Analytics {
|
||||||
project: string
|
public projectId: string;
|
||||||
appName: string
|
public appName: string;
|
||||||
apiEndPoint: string
|
public apiEndPoint: string;
|
||||||
secretKey: string = ''
|
public secretKey: string = '';
|
||||||
constructor (optionsArg: {
|
constructor(optionsArg: {
|
||||||
projectArg: string
|
projectId: string;
|
||||||
appNameArg: string
|
appName: string;
|
||||||
apiEndPointArg: string
|
apiEndPoint: string;
|
||||||
secretKeyArg?: string
|
secretKey?: string;
|
||||||
}) {
|
}) {
|
||||||
this.project = optionsArg.projectArg
|
this.projectId = optionsArg.projectId;
|
||||||
this.appName = optionsArg.appNameArg
|
this.appName = optionsArg.appName;
|
||||||
this.apiEndPoint = optionsArg.apiEndPointArg
|
this.apiEndPoint = optionsArg.apiEndPoint;
|
||||||
if (optionsArg.secretKeyArg) {
|
if (optionsArg.secretKey) {
|
||||||
this.secretKey = optionsArg.secretKeyArg
|
this.secretKey = optionsArg.secretKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async recordEvent (identifierArg: string, analyticsDataArg: any) {
|
async recordEvent(eventIdArg: string, analyticsDataArg: any) {
|
||||||
let dataToSend = {
|
let dataToSend = {
|
||||||
project: this.project,
|
projectId: this.projectId,
|
||||||
appName: this.appName,
|
appName: this.appName,
|
||||||
identifier: identifierArg,
|
eventId: eventIdArg,
|
||||||
analyticsData: analyticsDataArg
|
analyticsData: analyticsDataArg
|
||||||
}
|
};
|
||||||
console.log(dataToSend)
|
await plugins.smartrequest
|
||||||
await plugins.smartrequest.post(this.apiEndPoint, {
|
.postJson(this.apiEndPoint, {
|
||||||
headers: {
|
headers: {
|
||||||
'authenticate': this.secretKey,
|
authenticate: this.secretKey,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
requestBody: dataToSend
|
requestBody: dataToSend
|
||||||
}).catch(err => {
|
})
|
||||||
console.log(err)
|
.catch(err => {
|
||||||
})
|
console.log(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import 'typings-global'
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
import * as smartrequest from 'smartrequest'
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
import * as smartq from 'smartq'
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
smartrequest,
|
smartrequest,
|
||||||
smartq
|
smartpromise
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
{
|
{
|
||||||
"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
|
||||||
|
},
|
||||||
|
"defaultSeverity": "warning"
|
||||||
}
|
}
|
||||||
|
102
yarn.lock
102
yarn.lock
@ -10,14 +10,18 @@
|
|||||||
"@types/promises-a-plus" "*"
|
"@types/promises-a-plus" "*"
|
||||||
|
|
||||||
"@types/chai-string@^1.1.30":
|
"@types/chai-string@^1.1.30":
|
||||||
version "1.1.30"
|
version "1.1.31"
|
||||||
resolved "https://registry.yarnpkg.com/@types/chai-string/-/chai-string-1.1.30.tgz#4d8744b31a5a2295fc01c981ed1e2d4c8a070f0a"
|
resolved "https://registry.yarnpkg.com/@types/chai-string/-/chai-string-1.1.31.tgz#a22f75d713f69da8c5cf34f8bc808a62cd249405"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/chai" "*"
|
"@types/chai" "*"
|
||||||
|
|
||||||
"@types/chai@*", "@types/chai@^3.4.35":
|
"@types/chai@*":
|
||||||
version "3.4.35"
|
version "4.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-3.4.35.tgz#e8d65f83492d2944f816fc620741821c28a8c900"
|
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.0.4.tgz#fe86315d9a66827feeb16f73bc954688ec950e18"
|
||||||
|
|
||||||
|
"@types/chai@^3.4.35":
|
||||||
|
version "3.5.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-3.5.2.tgz#c11cd2817d3a401b7ba0f5a420f35c56139b1c1e"
|
||||||
|
|
||||||
"@types/glob@*":
|
"@types/glob@*":
|
||||||
version "5.0.32"
|
version "5.0.32"
|
||||||
@ -57,9 +61,9 @@ assertion-error@^1.0.1:
|
|||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.0.2.tgz#13ca515d86206da0bac66e834dd397d87581094c"
|
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.0.2.tgz#13ca515d86206da0bac66e834dd397d87581094c"
|
||||||
|
|
||||||
balanced-match@^0.4.1:
|
balanced-match@^1.0.0:
|
||||||
version "0.4.2"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
|
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
|
||||||
|
|
||||||
beautycolor@^1.0.7:
|
beautycolor@^1.0.7:
|
||||||
version "1.0.11"
|
version "1.0.11"
|
||||||
@ -72,11 +76,11 @@ bindings@^1.2.1:
|
|||||||
version "1.3.0"
|
version "1.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.3.0.tgz#b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7"
|
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.3.0.tgz#b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7"
|
||||||
|
|
||||||
brace-expansion@^1.0.0:
|
brace-expansion@^1.1.7:
|
||||||
version "1.1.6"
|
version "1.1.8"
|
||||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9"
|
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292"
|
||||||
dependencies:
|
dependencies:
|
||||||
balanced-match "^0.4.1"
|
balanced-match "^1.0.0"
|
||||||
concat-map "0.0.1"
|
concat-map "0.0.1"
|
||||||
|
|
||||||
chai-as-promised@^6.0.0:
|
chai-as-promised@^6.0.0:
|
||||||
@ -86,8 +90,8 @@ chai-as-promised@^6.0.0:
|
|||||||
check-error "^1.0.2"
|
check-error "^1.0.2"
|
||||||
|
|
||||||
chai-string@^1.3.0:
|
chai-string@^1.3.0:
|
||||||
version "1.3.0"
|
version "1.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/chai-string/-/chai-string-1.3.0.tgz#df6139f294391b1035be5606f60a843b3a5041e7"
|
resolved "https://registry.yarnpkg.com/chai-string/-/chai-string-1.4.0.tgz#359140c051d36a4e4b1a5fc6b910152f438a8d49"
|
||||||
|
|
||||||
chai@^3.5.0:
|
chai@^3.5.0:
|
||||||
version "3.5.0"
|
version "3.5.0"
|
||||||
@ -161,13 +165,13 @@ function-bind@^1.0.2, function-bind@^1.1.0:
|
|||||||
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"
|
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"
|
||||||
|
|
||||||
glob@^7.0.0:
|
glob@^7.0.0:
|
||||||
version "7.1.1"
|
version "7.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8"
|
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
|
||||||
dependencies:
|
dependencies:
|
||||||
fs.realpath "^1.0.0"
|
fs.realpath "^1.0.0"
|
||||||
inflight "^1.0.4"
|
inflight "^1.0.4"
|
||||||
inherits "2"
|
inherits "2"
|
||||||
minimatch "^3.0.2"
|
minimatch "^3.0.4"
|
||||||
once "^1.3.0"
|
once "^1.3.0"
|
||||||
path-is-absolute "^1.0.0"
|
path-is-absolute "^1.0.0"
|
||||||
|
|
||||||
@ -189,8 +193,8 @@ inherits@2:
|
|||||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
||||||
|
|
||||||
interpret@^1.0.0:
|
interpret@^1.0.0:
|
||||||
version "1.0.1"
|
version "1.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.1.tgz#d579fb7f693b858004947af39fa0db49f795602c"
|
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.3.tgz#cbc35c62eeee73f19ab7b10a801511401afc0f90"
|
||||||
|
|
||||||
is-callable@^1.1.1, is-callable@^1.1.3:
|
is-callable@^1.1.1, is-callable@^1.1.3:
|
||||||
version "1.1.3"
|
version "1.1.3"
|
||||||
@ -235,11 +239,11 @@ memwatch-next@^0.3.0:
|
|||||||
bindings "^1.2.1"
|
bindings "^1.2.1"
|
||||||
nan "^2.3.2"
|
nan "^2.3.2"
|
||||||
|
|
||||||
minimatch@^3.0.2:
|
minimatch@^3.0.4:
|
||||||
version "3.0.3"
|
version "3.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774"
|
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
|
||||||
dependencies:
|
dependencies:
|
||||||
brace-expansion "^1.0.0"
|
brace-expansion "^1.1.7"
|
||||||
|
|
||||||
minimist@^1.2.0:
|
minimist@^1.2.0:
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
@ -270,6 +274,10 @@ path-is-absolute@^1.0.0:
|
|||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
|
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
|
||||||
|
|
||||||
|
path-parse@^1.0.5:
|
||||||
|
version "1.0.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1"
|
||||||
|
|
||||||
pretty-bytes@^4.0.2:
|
pretty-bytes@^4.0.2:
|
||||||
version "4.0.2"
|
version "4.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-4.0.2.tgz#b2bf82e7350d65c6c33aa95aaa5a4f6327f61cd9"
|
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-4.0.2.tgz#b2bf82e7350d65c6c33aa95aaa5a4f6327f61cd9"
|
||||||
@ -281,20 +289,14 @@ rechoir@^0.6.2:
|
|||||||
resolve "^1.1.6"
|
resolve "^1.1.6"
|
||||||
|
|
||||||
resolve@^1.1.6:
|
resolve@^1.1.6:
|
||||||
version "1.2.0"
|
version "1.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.2.0.tgz#9589c3f2f6149d1417a40becc1663db6ec6bc26c"
|
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.4.0.tgz#a75be01c53da25d934a98ebd0e4c4a7312f92a86"
|
||||||
|
dependencies:
|
||||||
|
path-parse "^1.0.5"
|
||||||
|
|
||||||
semver@^5.3.0:
|
semver@^5.3.0:
|
||||||
version "5.3.0"
|
version "5.4.1"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"
|
||||||
|
|
||||||
shelljs@^0.7.4:
|
|
||||||
version "0.7.6"
|
|
||||||
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.6.tgz#379cccfb56b91c8601e4793356eb5382924de9ad"
|
|
||||||
dependencies:
|
|
||||||
glob "^7.0.0"
|
|
||||||
interpret "^1.0.0"
|
|
||||||
rechoir "^0.6.2"
|
|
||||||
|
|
||||||
shelljs@^0.7.8:
|
shelljs@^0.7.8:
|
||||||
version "0.7.8"
|
version "0.7.8"
|
||||||
@ -322,14 +324,7 @@ smartdelay@^1.0.3:
|
|||||||
smartq "^1.1.1"
|
smartq "^1.1.1"
|
||||||
typings-global "^1.0.16"
|
typings-global "^1.0.16"
|
||||||
|
|
||||||
smartq@^1.1.0, smartq@^1.1.1:
|
smartq@^1.1.1, smartq@^1.1.6:
|
||||||
version "1.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.1.tgz#efb358705260d41ae18aef7ffd815f7b6fe17dd3"
|
|
||||||
dependencies:
|
|
||||||
typed-promisify "^0.3.0"
|
|
||||||
typings-global "^1.0.14"
|
|
||||||
|
|
||||||
smartq@^1.1.6:
|
|
||||||
version "1.1.6"
|
version "1.1.6"
|
||||||
resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.6.tgz#0c1ff4336d95e95b4f1fdd8ccd7e2c5a323b8412"
|
resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.6.tgz#0c1ff4336d95e95b4f1fdd8ccd7e2c5a323b8412"
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -337,11 +332,11 @@ smartq@^1.1.6:
|
|||||||
util.promisify "^1.0.0"
|
util.promisify "^1.0.0"
|
||||||
|
|
||||||
smartrequest@^1.0.4:
|
smartrequest@^1.0.4:
|
||||||
version "1.0.4"
|
version "1.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/smartrequest/-/smartrequest-1.0.4.tgz#86af2163ae28f1031b01c2d8ad8c429733920611"
|
resolved "https://registry.yarnpkg.com/smartrequest/-/smartrequest-1.0.6.tgz#a006454332453b0a70d38a003a29963d039a7783"
|
||||||
dependencies:
|
dependencies:
|
||||||
smartq "^1.1.0"
|
smartq "^1.1.1"
|
||||||
typings-global "^1.0.14"
|
typings-global "^1.0.17"
|
||||||
|
|
||||||
smartshell@^1.0.6:
|
smartshell@^1.0.6:
|
||||||
version "1.0.13"
|
version "1.0.13"
|
||||||
@ -373,18 +368,7 @@ type-detect@^1.0.0:
|
|||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2"
|
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2"
|
||||||
|
|
||||||
typed-promisify@^0.3.0:
|
typings-global@^1.0.14, typings-global@^1.0.16, typings-global@^1.0.17, typings-global@^1.0.19:
|
||||||
version "0.3.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/typed-promisify/-/typed-promisify-0.3.0.tgz#1ba0af5e444c87d8047406f18ce49092a1191853"
|
|
||||||
|
|
||||||
typings-global@^1.0.14:
|
|
||||||
version "1.0.14"
|
|
||||||
resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.14.tgz#ab682720a03d6b9278869fb5c30c30d7dc61d12c"
|
|
||||||
dependencies:
|
|
||||||
semver "^5.3.0"
|
|
||||||
shelljs "^0.7.4"
|
|
||||||
|
|
||||||
typings-global@^1.0.16, typings-global@^1.0.19:
|
|
||||||
version "1.0.20"
|
version "1.0.20"
|
||||||
resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.20.tgz#3da769c54db538247c5d877d1d9e97eb2ec981ff"
|
resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.20.tgz#3da769c54db538247c5d877d1d9e97eb2ec981ff"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
Reference in New Issue
Block a user