Skip to content

Commit

Permalink
Add typings, markdown lint, tape to tap (#9)
Browse files Browse the repository at this point in the history
* Add typings

* Switch tape to tap

* Update README.md

* Update package.json
- add markdown lint
- switch tape to tap
- add dependency

* Removed coverall

* Update .gitignore
  • Loading branch information
gnought authored Feb 11, 2020
1 parent ebe0175 commit cd3eb24
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 37 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,3 @@ jobs:
- name: Run tests
run: |
npm run test:ci
- name: Coveralls Parallel
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel: true

coverage:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
31 changes: 27 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
Expand All @@ -17,14 +18,36 @@ coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
# Commenting this out is preferred by some people, see
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules

# Users Environment Variables
.lock-wscript
.vscode
*code-workspace

# 0x
flamegraph.html
.__*
profile*

# mac files
.DS_Store

# vim swap files
*.swp

# lock files
package-lock.json

# generated code
test/types/*.js
test/types/*.map

# test tap report
out.tap
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<!-- markdownlint-disable MD013 MD024 -->
# aedes-packet
![](https://github.com/moscajs/aedes-packet/workflows/ci/badge.svg)
[![Dependencies Status](https://david-dm.org/moscajs/aedes-packet/status.svg)](https://david-dm.org/moscajs/aedes-packet)
[![devDependencies Status](https://david-dm.org/moscajs/aedes-packet/dev-status.svg)](https://david-dm.org/moscajs/aedes-packet?type=dev)
<br/>

![ci](https://github.com/moscajs/aedes-packet/workflows/ci/badge.svg)
[![Known Vulnerabilities](https://snyk.io/test/github/moscajs/aedes-packet/badge.svg)](https://snyk.io/test/github/moscajs/aedes-packet)
[![Coverage Status](https://coveralls.io/repos/moscajs/aedes-packet/badge.svg?branch=master&service=github)](https://coveralls.io/github/moscajs/aedes-packet?branch=master)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)\
[![Dependencies Status](https://david-dm.org/moscajs/aedes-packet/status.svg)](https://david-dm.org/moscajs/aedes-packet)
[![devDependencies Status](https://david-dm.org/moscajs/aedes-packet/dev-status.svg)](https://david-dm.org/moscajs/aedes-packet?type=dev)\
[![NPM version](https://img.shields.io/npm/v/aedes-packet.svg?style=flat)](https://www.npmjs.com/package/aedes-packet)
[![NPM downloads](https://img.shields.io/npm/dm/aedes-packet.svg?style=flat)](https://www.npmjs.com/package/aedes-packet)

Basic data structure for packets in [Aedes](http://npm.im/aedes), packaged up for perf and reusability between modules.
Basic data structure for packets in [Aedes](https://www.npmjs.com/aedes), packaged up for perf and reusability between modules.

See [./packet.js](./packet.js) and [./test.js](./test.js) for
documentation and usage.

[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

## Collaborators

* [__Gnought__](https://github.com/gnought)
Expand Down
24 changes: 16 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
"description": "Basic data structure for packets in Aedes ",
"main": "packet.js",
"scripts": {
"lint": "standard --verbose | snazzy",
"unit": "tape test.js | faucet",
"test": "npm run lint && npm run unit",
"coverage": "nyc --reporter=lcov tape test.js",
"test:ci": "npm run lint && npm run coverage",
"lint": "npm run lint:standard && npm run lint:typescript && npm run lint:markdown",
"lint:standard": "standard --verbose | snazzy",
"lint:typescript": "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin test/types/*.ts packet.d.ts",
"lint:markdown": "markdownlint README.md",
"unit": "tap --no-esm -J test.js",
"typescript": "tsc --project ./test/types/tsconfig.json",
"test": "npm run lint && npm run unit && npm run typescript",
"test:ci": "npm run test",
"license-checker": "license-checker --production --onlyAllow='MIT;ISC;BSD-3-Clause;BSD-2-Clause'"
},
"pre-commit": [
Expand Down Expand Up @@ -36,14 +39,19 @@
"url": "https://github.com/moscajs/aedes-packet/issues"
},
"homepage": "https://github.com/moscajs/aedes-packet#readme",
"dependencies": {},
"dependencies": {
"mqtt-packet": "^6.3.0"
},
"devDependencies": {
"@types/node": "^12.12.26",
"@typescript-eslint/eslint-plugin": "^2.19.0",
"@typescript-eslint/parser": "^2.19.0",
"faucet": "0.0.1",
"license-checker": "^25.0.1",
"nyc": "^15.0.0",
"markdownlint-cli": "^0.22.0",
"pre-commit": "^1.2.2",
"snazzy": "^8.0.0",
"standard": "^14.3.1",
"tape": "^4.13.0"
"tap": "^14.10.6"
}
}
19 changes: 19 additions & 0 deletions packet.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint no-unused-vars: 0 */
/* eslint no-undef: 0 */
/* eslint space-infix-ops: 0 */

/// <reference types="node" />

import { Packet as IPacket } from 'mqtt-packet'

declare namespace aedes {

type AedesPacket = IPacket & {
brokerId: string
brokerCounter: number
}

function Packet(object?: AedesPacket) : aedes.AedesPacket
}

export = aedes
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

var test = require('tape')
var { test } = require('tap')
var Packet = require('./')

test('Packet defaults - PUBLISH, QoS 0', function (t) {
Expand Down
21 changes: 21 additions & 0 deletions test/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint no-unused-vars: 0 */
/* eslint no-undef: 0 */

import { Packet } from '../../packet'

var p = Packet()
p = Packet({
cmd: 'publish',
topic: 'hello',
payload: Buffer.from('world'),
qos: 0,
dup: false,
retain: false,
brokerId: 'afds8f',
brokerCounter: 10
})
p = Packet({
cmd: 'pingresp',
brokerId: 'ab7d9',
brokerCounter: 3
})
11 changes: 11 additions & 0 deletions test/types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noEmit": true,
"strict": true
},
"files": [
"./index.ts"
]
}

0 comments on commit cd3eb24

Please sign in to comment.