This commit is contained in:
glmdev 2019-06-24 09:28:15 -05:00
commit b080b33b88
4 changed files with 108 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.env
env/
node_modules/*

47
devbug.js Normal file
View File

@ -0,0 +1,47 @@
const web = require('restler')
const devbug = {
outs: {},
options: false,
out(key, what, group = false){
if ( !this.options ) console.log('Please specify the DevBug server and project using the dbsetup() method.')
if ( group ){
if ( Object.keys(this.outs).includes(group) && typeof this.outs[group] === 'object' ) this.outs[group][key] = what
else {
this.outs[group] = {}
this.outs[group][key] = what
}
}
else this.outs[key] = what
},
breakpoint(html = false, name = false){
if ( !this.options ){ console.log('Please specify the DevBug server and project using the dbsetup() method.'); process.exit(1) }
const url = this.options.server+'api/v1/out/'+this.options.project
const caller = (new Error()).stack.split('at')[2].trim()
web.post(url, {
multipart: true,
data: {
data: JSON.stringify({
brief: (name ? name : 'Breakpoint: ')+caller,
data: this.outs
})
}
}).on('complete', (data) => {
console.log('DevBug POST complete.')
console.log(data)
process.exit(0)
})
},
setup(user_options = {}){
const options = {...{
server: 'http://localhost:8000/',
project: '5ab5de6e-a83b-44dc-be28-0727e09170c9'
}, ...user_options}
this.options = options
}
}
global.devbug = devbug
global.out = devbug.out.bind(devbug)
global.breakpoint = devbug.breakpoint.bind(devbug)
global.dbsetup = devbug.setup.bind(devbug)
module.exports = exports = devbug

12
package.json Normal file
View File

@ -0,0 +1,12 @@
{
"name": "devbugjs",
"version": "0.1.0",
"description": "Node.js client for DevBug debugging server.",
"main": "devbug.js",
"repository": "https://git.glmdev.tech/glmdev/devbugjs",
"author": "Garrett Mills",
"license": "MIT",
"dependencies": {
"restler": "^3.4.0"
}
}

46
yarn.lock Normal file
View File

@ -0,0 +1,46 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
iconv-lite@0.2.11:
version "0.2.11"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.2.11.tgz#1ce60a3a57864a292d1321ff4609ca4bb965adc8"
integrity sha1-HOYKOleGSiktEyH/RgnKS7llrcg=
qs@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-1.2.0.tgz#ed079be28682147e6fd9a34cc2b0c1e0ec6453ee"
integrity sha1-7Qeb4oaCFH5v2aNMwrDB4OxkU+4=
restler@^3.4.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/restler/-/restler-3.4.0.tgz#741ec0b3d16b949feea2813d0c3c68529e888d9b"
integrity sha1-dB7As9FrlJ/uooE9DDxoUp6IjZs=
dependencies:
iconv-lite "0.2.11"
qs "1.2.0"
xml2js "0.4.0"
yaml "0.2.3"
sax@0.5.x:
version "0.5.8"
resolved "https://registry.yarnpkg.com/sax/-/sax-0.5.8.tgz#d472db228eb331c2506b0e8c15524adb939d12c1"
integrity sha1-1HLbIo6zMcJQaw6MFVJK25OdEsE=
xml2js@0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.0.tgz#124fc4114b4129c810800ecb2ac86cf25462cb9a"
integrity sha1-Ek/EEUtBKcgQgA7LKshs8lRiy5o=
dependencies:
sax "0.5.x"
xmlbuilder ">=0.4.2"
xmlbuilder@>=0.4.2:
version "13.0.2"
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-13.0.2.tgz#02ae33614b6a047d1c32b5389c1fdacb2bce47a7"
integrity sha512-Eux0i2QdDYKbdbA6AM6xE4m6ZTZr4G4xF9kahI2ukSEMCzwce2eX9WlTI5J3s+NU7hpasFsr8hWIONae7LluAQ==
yaml@0.2.3:
version "0.2.3"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-0.2.3.tgz#b5450e92e76ef36b5dd24e3660091ebaeef3e5c7"
integrity sha1-tUUOkudu82td0k42YAkeuu7z5cc=